Vim 系列 (一) Using Marks in Vim

Guide

Vim's motion commands are very flexible and work well for general use. You can go to the beginning of a line, replace a word, or change a sentence. What about things that are semantically relevant to your files, like an important or buggy function definition, the point of entry for your application, or a stack you're trying to trace? For these, you can use marks (read as: "bookmarks"). These are "save points" in your files that you can set, jump between, and even use with commands.

Vim 的运动命令非常灵活,适用于一般用途。您可以转到行首、替换单词或更改句子。如果内容与文件相关,例如重要或错误的函数定义、应用程序的入口点或尝试跟踪的堆栈,该怎么办?对于这些,您可以使用标记(读作:"书签")。这些是文件中的"保存点",您可以设置、在它们之间跳转,甚至与命令一起使用。

Local and Global Marks 本地和全球商标

A local mark is specific to a particular file and is indicated by a lowercase letter, while global marks are universal across all of your files and use uppercase letters. That is, many files can have an a`` mark, while A`` points to a particular location in one particular file.

本地标记特定于特定文件,由小写字母表示,而全局标记在所有文件中都是通用的,并使用大写字母。也就是说,许多文件可以有一个 a`` 标记,同时 A`` 指向一个特定文件中的特定位置。

Viewing Marks 查看标记

View a list of your current marks with :marks. Note that marks are invisible in vim without the use of a (plug-in).

Setting Marks 设置标记

Set marks with m key in normal mode. To set a local mark of a where the cursor is, type ma. To jump to this location, type ```a`` anywhere in the file.

在正常模式下用 m 键设置标记。若要设置光标所在位置的 a 本地标记,请键入 ma 。若要跳转到此位置,请在文件中的任意位置键入 ```a`` 。

Deleting Marks 删除标记

You can delete marks with the :delm command. To delete marks a``, e, and ```G, you would type :delm aeG. You can delete all local marks with :delm!.

您可以使用该 :delm 命令删除标记。若要删除标记 a`` 、 e 和 ```G ,请键入 :delm aeG 。您可以使用 :delm! 删除所有本地标记。

Some tips 一些提示

  • Marks are motions, so you can use them with actions. For example, y`w will copy everything between your current cursor location and the w`` mark. 标记是动作,因此您可以将它们与动作一起使用。例如, ``y`w`` 将复制当前光标位置和 w`` 标记之间的所有内容。
  • will return you to the last place you jumped from 复制代码
    ```````` 将把你送回你最后跳下的地方
  • 0`` will return you to the last file you had open before you quit vim 0`` 将返回到退出 Vim 之前打开的最后一个文件
  • Using ' (single-quote) instead of (backtick) will jump you to the first non-blank character on the same line as the mark 使用 `'` (单引号) 而不是 (反引号) 会跳转到与标记同一行的第一个非空白字符
  • If set V`` to the top of your `.vimrc` file, you can jump to it from any file (saved between `vim` sessions by default) 如果设置为 V`` 文件顶部,则可以从任何 .vimrc 文件跳转到该文件(默认情况下在会话之间 vim 保存)
  • You can cycle through local marks with [``` / ] 您可以使用 ``[ / ``]``` 循环浏览本地标记
  • The kshenoy/vim-signature plug-in will add visual indications of marks to your line numbers, as well as giving you the ability to delete marks with dm[mark letter], assign the next available mark with m,, and more
    kshenoy/vim-signature 插件将为您的行号添加标记的视觉指示,并使您能够删除 dm[mark letter] 标记 ,使用 m, ,分配下一个可用标记 ,等等
相关推荐
涛涛讲AI几秒前
wkhtmltopdf 实现批量对网页转为图片的好工具,快速实现大量卡片制作
linux·服务器·windows·windows效率工具
破刺不会编程14 分钟前
什么是进程?
linux·运维·服务器
大数据魔法师1 小时前
Redis(一) - Redis安装教程(Windows + Linux)
linux·windows·redis
Y1anoohh1 小时前
驱动学习专栏--字符设备驱动篇--2_字符设备注册与注销
linux·c语言·驱动开发·学习
.R^O^2 小时前
计算机知识
linux·服务器·网络·安全
卡戎-caryon2 小时前
【Linux网络与网络编程】11.数据链路层mac帧协议&&ARP协议
linux·服务器·网络·笔记·tcp/ip·数据链路层
夜月yeyue2 小时前
STM32启动流程详解
linux·c++·stm32·单片机·嵌入式硬件·c#
叶羽西2 小时前
Windows VsCode Terminal窗口使用Linux命令
ide·vscode·编辑器
夜月yeyue2 小时前
VScode+OpenOCD+HTOS栈回溯在国产mcu芯片上完全调试
c语言·ide·vscode·单片机·嵌入式硬件·编辑器
烛.照1033 小时前
RabbitMQ消息的可靠性
linux·docker·rabbitmq