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, ,分配下一个可用标记 ,等等
相关推荐
A小辣椒1 天前
TShark:Wireshark CLI 功能
linux
A小辣椒1 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao2 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334662 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪2 天前
linux 拷贝文件或目录到指定的位置
linux
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
bush43 天前
嵌入式linux学习记录十四、术语
linux·嵌入式
VidDown3 天前
VidDown 工具站:免费、本地优先的开发者工具箱
javascript·编辑器·音视频·视频编解码·视频
载数而行5203 天前
Linux 11 动态监控指令top
linux