vim 中的 % 字符是什么意思?

What is the meaning of the % character in vim?

vim wikia 页面提供以下搜索和替换说明:

:%s/foo/bar/g

Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.

:s/foo/bar/g

Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.

...

我可以看到 % 字符导致搜索整个缓冲区。

vim中的%字符是什么意思?是引用当前缓冲区的变量吗?

了解如何查找命令和导航内置 :help;它内容全面,提供了许多技巧。您不会像其他编辑器那样快速学习 Vim,但如果您致力于不断学习,它将被证明是一个非常强大和高效的编辑器。

您可以通过以下方式找到信息:

查找命令::help :substitute

  :[range]s[ubstitute]/{pattern}/{string}/[flags] [count]

啊,前面的东西叫范围。再往下,有一个link:

      Also see |cmdline-ranges|.

:help [range] 也会带你去。)这解释了 % 的含义,以及直接访问的帮助关键字。

%       equal to 1,$ (the entire file)        *:%*