How do I make Vim go inside paired characters automatically during Insert Mode?
-
27-04-2021 - |
Question
I always type paired characters by pairs:
'' "" () [] {} <>
How do I map Vim immediately jump inside them when I type them during Insert Mode? I tried some googling but I can't seem to get the right search term.
Solution
Use the AutoClose
plugin, which will insert the closing brace for you, leaving your cursor inside them. If you type the matching bracket quickly enough, it will move your cursor outside the pair.
OTHER TIPS
Without using any plugin, I found out I could use this:
inoremap '' ''<esc>i
inoremap "" ""<esc>i
inoremap () ()<esc>i
inoremap [] []<esc>i
inoremap {} {}<esc>i
inoremap <> <><esc>i
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow