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, ,分配下一个可用标记 ,等等
相关推荐
milo.qu15 小时前
RockyLinux9.7 docker部署Jisti Meet
linux·docker·容器
GanGanGanGan_15 小时前
CentOS 7.9 glibc 2.17 源码编译升级到 glibc 2.31
linux·运维·centos·glibc
charlie11451419116 小时前
嵌入式Linux驱动开发——class 和 device 模型 - 自动创建设备节点的幕后机制
linux·运维·驱动开发
枳实-叶17 小时前
【Linux驱动开发】第四天:dmesg日志全解+驱动加载失败极速排查
linux·运维·驱动开发
wdfk_prog18 小时前
正常关闭虚拟机时,不要点“关机”,而要点“关闭客户机”
linux·c语言·网络·ide·vscode
fish_xk19 小时前
Linux开方工具
linux·运维·服务器
用户23678298016821 小时前
Linux find 命令深度解析:从递归遍历到性能优化的完整实现
linux
ascarl20101 天前
Linux.do 帖子整理:AI 调用 Chrome DevTools 调试前端页面
linux·前端·人工智能
Slow菜鸟1 天前
Docker 学习篇(三)| Docker安装指南(Linux版)
linux·学习·docker
liuluyang5301 天前
linux kernel CONFIG_KCMP解析
linux·运维·服务器