Skip to main content
added 150 characters in body
Source Link
Vivian De Smedt
  • 21.1k
  • 5
  • 22
  • 40

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

This mapping:

  • Switch to Normal mode <Esc>
  • Search for a closing brace (), }, ]) or a $ /[\])}$]
  • Switch back to insert mode a

But it is not exactly the same of going one level up in nesting.

If you activate the builtin matchit plugin (runtime macros/matchit.vim) you could do:

imap <Tab> <Esc>]%a

It uses the ]% which is the equivalent of ]) but for all the 'braces' considered by matchit.

Remark: It doesn't support $ because for $ the open and closing brace characters are the same which make determining the level of nesting much more complex.

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

This mapping:

  • Switch to Normal mode <Esc>
  • Search for a closing brace (), }, ]) or a $ /[\])}$]
  • Switch back to insert mode a

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

This mapping:

  • Switch to Normal mode <Esc>
  • Search for a closing brace (), }, ]) or a $ /[\])}$]
  • Switch back to insert mode a

But it is not exactly the same of going one level up in nesting.

If you activate the builtin matchit plugin (runtime macros/matchit.vim) you could do:

imap <Tab> <Esc>]%a

It uses the ]% which is the equivalent of ]) but for all the 'braces' considered by matchit.

Remark: It doesn't support $ because for $ the open and closing brace characters are the same which make determining the level of nesting much more complex.

added 150 characters in body
Source Link
Vivian De Smedt
  • 21.1k
  • 5
  • 22
  • 40

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

This mapping:

  • Switch to Normal mode <Esc>
  • Search for a closing brace (), }, ]) or a $ /[\])}$]
  • Switch back to insert mode a

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a

This mapping:

  • Switch to Normal mode <Esc>
  • Search for a closing brace (), }, ]) or a $ /[\])}$]
  • Switch back to insert mode a
Source Link
Vivian De Smedt
  • 21.1k
  • 5
  • 22
  • 40

I would do:

inoremap <Tab> <Esc>/[\])}$]<CR>a