[[和]]在vim中做了什么?

时间:2013-03-26 11:39:31

标签: vim vi

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

我的猜测是[[]]会转到下一个实例,但我无法弄清楚是什么。

4 个答案:

答案 0 :(得分:4)

尝试:help ]]

  

]] [count]个部分前进或下一个'{'部分               第一栏。

进一步阅读::help section

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

答案 1 :(得分:3)

来自:help [[

[[          [count] sections backward or to the previous '{' in
            the first column.  |exclusive|
            Note that |exclusive-linewise| often applies.

答案 2 :(得分:0)

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

答案 3 :(得分:0)

我从未发现[[]]的默认行为有用UNTIL我从: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>