Vim:撇号(')或反引号(`)后跟数字做什么

时间:2014-12-22 10:30:30

标签: vim keyboard-shortcuts

我试图学习how to use marks in Vim,并且在击打反击后不小心碰了一个数字而不是一个字母。结果我几天前编辑的文件在当前缓冲区中打开。点击其他数字会打开其他最近编辑的文件,但不会按任何特定顺序打开。此外,关闭和重新开放Vim会进一步重新调整订单。任何人都可以解释它的作用以及如何使用此功能吗?

2 个答案:

答案 0 :(得分:5)

编号标记在.viminfo文件中设置,您无法直接设置。 Vim的帮助文档解释了它是如何工作的:

Numbered marks '0 to '9 are quite different.  They can not be set directly.
They are only present when using a viminfo file |viminfo-file|.  Basically '0
is the location of the cursor when you last exited Vim, '1 the last but one
time, etc.  Use the "r" flag in 'viminfo' to specify files for which no
Numbered mark should be stored.  See |viminfo-file-marks

Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
numbered marks ('0 to '9) are a bit special.  When the viminfo file is written
(when exiting or with the ":wviminfo" command), '0 is set to the current cursor
position and file.  The old '0 is moved to '1, '1 to '2, etc.  This
resembles what happens with the "1 to "9 delete registers.  If the current
cursor position is already present in '0 to '9, it is moved to '0, to avoid
having the same position twice.  The result is that with "'0", you can jump
back to the file and line where you exited Vim. 

答案 1 :(得分:2)

一切都在帮助之中。从:help marks开始,在相关命令之后,有一个关于标记的部分,列出:

  

'0 - '9个编号标记,由.viminfo文件

设置

还有更多信息:

  

编号标记'0到'9是完全不同的。它们不能直接设置。   它们仅在使用viminfo文件时出现| viminfo-file |。基本上'0   是你上次退出Vim时光标的位置,'1是最后一个而是一个   使用'viminfo'中的“r”标志来指定no的文件   应存储编号标记。见| viminfo-file-marks |。