Search code examples
vim

Modify Vim section jumping with [[ and ]]?


Is it possible to change [[ and ]] to jump to the nearest { or } in the first column (as it does by default), or in the first column after some number of tabs?

For example, I'd like it to work for both of these:

function a()
{
}
<tab><tab>*function b()
<tab><tab>*{
<tab><tab>*}

Solution

  • Not really and the doc even suggests making custom mappings, like these:

    nnoremap ]] :call search('^\s*}', 'e')<CR>
    nnoremap [[ :call search('^\s*{', 'eb')<CR>
    

    See :help search().