关于[[和]]的使用,请注意vim文档中motion.txt的以下内容:
If your '{' or '}' are not in the first column, and you would like to use "[["
and "]]" anyway, try these mappings:
:map [[ ?{w99[{
:map ][ /}b99]}
:map ]] j0[[%/{
:map [] k$][%?}
只需使用]m跳转到下一个方法,[m即可跳转到上一个方法。
在你的~/.vimrc,你可以做
nnoremap ]m ]mzz
nnoremap [m [mzz
这样,每次在方法之间跳转时,都会将该方法放在屏幕的中央。