Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to jump into parenthesis in VIM

Tags:

vim

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.

like image 718
wundervoll Avatar asked Jun 12 '12 01:06

wundervoll


People also ask

How do I jump to the next word in Vim?

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.

How do you jump in front of a line in Vim?

Press 0 to go to the beginning of a line, or ^ to go to the first non-blank character in a line.

How do I select text between brackets in vim?

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.)

How do you move cursor to a specific character in Vim?

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.


1 Answers

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.)

like image 70
sarnold Avatar answered Oct 13 '22 00:10

sarnold