Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do [[ and ]] do in vim?

Tags:

vim

vi

In vim (and vi) if I am in the command mode and I type [[ it appears to go to the start of the the file, and if I type ]] it appears to go to the end of the file. But I thought that gg and G were the start/end of file commands, so are [[ and ]] doing something different?

My guess is that [[ and ]] will go to the next instance of something, but I can't figure out what.

like image 917
Tom Avatar asked May 13 '26 05:05

Tom


1 Answers

I never found the default behavior of [[ and ]] useful UNTIL I saw this tip from :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>
like image 189
Niko Bellic Avatar answered May 17 '26 10:05

Niko Bellic