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, ,分配下一个可用标记 ,等等
相关推荐
郝学胜-神的一滴1 天前
使用Linux的read和write系统函数操作文件
linux·服务器·开发语言·数据库·c++·程序人生·软件工程
七七七七071 天前
【Linux 系统】打开文件和文件系统
linux·运维·spring
DeeplyMind1 天前
第二章:模块的编译与运行-7 Loading and Unloading Modules
linux·驱动开发
---学无止境---1 天前
Linux中驱动程序通过fasync异步通知应用程序的实现
linux
cccyi71 天前
Linux 进程间通信机制详解
linux·进程通信
北京迅为1 天前
【北京迅为】iTOP-4412精英版使用手册-第三十五章 WEB控制LED
linux·嵌入式硬件·嵌入式·4412
让我们一起加油好吗1 天前
【C++】封装红黑树模拟实现 set 和 map
linux·c++·set·map·红黑树
暴富奥利奥1 天前
完成docker方式的ros环境配置
linux·学习·docker·容器
秃头菜狗1 天前
十四、运行经典案例 wordcount
大数据·linux·hadoop
望获linux1 天前
【实时Linux实战系列】实时系统的可观测性:Prometheus 与 Grafana 集成
大数据·linux·服务器·开发语言·网络·操作系统