[[ 和 ]] 在 vi​​m 中做什么?

Tom*_*Tom 7 vi vim

在 vim(和 vi)中,如果我处于命令模式并且我键入[[它似乎会转到文件的开头,如果我键入]]它似乎会转到文件的末尾。但我认为ggG是文件命令的开始/结束,那么[[和是]]在做一些不同的事情吗?

我的猜测是,[[并将]]转到下一个实例,但我不知道是什么。

Nik*_*lic 6

我从来没有发现默认行为[[]]有用直到我看到这个提示:help section

If your '{' or '}' are not in the first column, and you would like to use "[["
and "]]" anyway, try these mappings:

   :map [[ ?{<CR>w99[{
   :map ][ /}<CR>b99]}
   :map ]] j0[[%/{<CR>
   :map [] k$][%?}<CR>
Run Code Online (Sandbox Code Playgroud)


vau*_*ult 5

AFAIK,

[[ : jump to function start
]] : jump to function end
Run Code Online (Sandbox Code Playgroud)

编辑:我还找到了一份备忘单,其中定义了:

(  [count] : sentences backward
)  [count] : sentences forward
{  [count] : paragraphs backward
}  [count] : paragraphs forward
]] [count] : sections forward or to the next '{' in the first column. When used after an operator, then the '}' in the first column.
][ [count] : sections forward or to the next '}' in the first column
[[ [count] : sections backward or to the previous '{' in the first column
]] [count] : sections backward or to the previous '}' in the first column
Run Code Online (Sandbox Code Playgroud)


Ing*_*kat 4

尝试:help ]]

]][count] 个部分向前或到第一列中的下一个“{”。

进一步阅读::help section.

专业提示:了解如何查找命令并导航内置:help;它很全面,并提供了许多技巧。您学习 Vim 的速度不会像其他编辑器那么快,但如果您致力于持续学习,它将证明它是一个非常强大且高效的编辑器。