Currently, I'm trying to learn VIM and disabled the arrow keys for all modes. When typing out new functions I always used to open and close the parenthesis at the same time in order to not forget them. Since, I cannot go back (no arrow keys) I was wondering how it is done in VIM because once closed, you are outside of the parenthesis.
Is it standard practice to exit INSERT mode, move into the parenthesis and enter INSERT mode again? Or do you simply leave the parenthesis open until you are finished?
I do know about the AutoClose script. The question serves more to understand the VIM way of doing things so I would like to know how other developers are overcoming this problem.
Press w (“word”) to move the cursor to the right one word at a time. Press b (“back”) to move the cursor to the left one word at a time. Press W or B to move the cursor past the adjacent punctuation to the next or previous blank space. Press e (“end”) to move the cursor to the last character of the current word.
Press 0 to go to the beginning of a line, or ^ to go to the first non-blank character in a line.
place the cursor on the opening parenthesis ( or braces { press esc key and press v to enter into the visual mode. now press the % symbol (this will select the whole text between parens inclusive) press the key y to yank (i.e. copy) the text (press d if you rather want to cut it.)
You can type f<character> to put the cursor on the next character and F<character> for the previous one. You can also use ; to repeat the operation and use , to repeat it in opposite direction.
Forgetting a closing parenthesis will cause highlighting problems later on, making it unlikely that you'd overlook them further.
I suggest getting in the habit of typing the arguments in the middle of the parenthesis as you're typing and close the parens once you're finished with the arguments. (If you're trying to learn vim
, anyway, this change doesn't seem too large to adapt to -- the amount of other things you'll have to adapt to is already pretty staggering.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With