3

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

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

4

4 回答 4

4

尝试:help ]]

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

延伸阅读::help section

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

于 2013-03-26T11:45:50.137 回答
4

我从来没有发现默认行为[[]]有用的直到我看到这个提示: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>
于 2017-01-23T20:03:12.803 回答
3

:help [[,

[[          [count] sections backward or to the previous '{' in
            the first column.  |exclusive|
            Note that |exclusive-linewise| often applies.
于 2013-03-26T11:44:46.173 回答
2

AFAIK,

[[ : jump to function start
]] : jump to function end

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

(  [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
于 2013-03-26T11:42:31.457 回答