I've recently started trying to learn Vim by setting up Vim keybindings in VSCode.
One thing I've noticed is that when I open a quote ""
, parenthesis ()
, or bracket {}
, VSCode will helpful add the closing quote/paren/bracket for me.
Since I'm now using Vim keybindings, it's now really frustrating to navigate around. I have to ESC
, navigate around that character, then i
back into insert mode to keep typing. It kinda breaks my flow.
Is there an efficient way to navigate around these characters? Or do I just have to get good at the ESC l a
combo?
CodePudding user response:
First, what you are using is not Vim. It's an incomplete reimplementation of Vim that may or may not work like Vim at all. Moreover, your current environment seems to have a number of features enabled that are not available out of the box in Vim, which makes your "Vim experience" even less Vim-like. If you want to learn Vim, do it in Vanilla Vim.
Second, automatically closing pairs is only useful for one thing: making sure that you don't forget the closing character.
Because you have to press a key anyway to leap over the automatically inserted character there is no gain whatsoever on the typing side, which makes the feature totally useless outside of the safety scenario:
" no auto-closing
f
o
o
(
b
a
r
)
{ 9 keystrokes
" auto-closing
f
o
o
(
b
a
r
→
{ 9 keystrokes
And it quickly enters aberration territory when it comes to Vim or a Vim emulator, where a misguided reading of the scriptures would force you to do something as silly as <Esc>la
just to avoid pressing the unclean <Right>
.
My advice, consider the pros and cons of auto-closing.
CodePudding user response:
To my knowledge if you're using the VSCode Vim (which by the question it seems you are doing), you can just press the matching closing bracket.
So if I'm in normal mode and I want to type int[5]
then the following keystrokes should work
iint[5]
(the first i
is to go to insert mode)
And your cursor will be after the closing square bracket.
If you want to do that in regular vim/neovim, I suggest a plugin like AutoPairs.