Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM navigate on insert mode

Tags:

vim

move

One of the things that bugs me the most about VIM is having to move while in insert mode. With any other programs I can use the arrow keys to move around but with VIM I have learned to use h/j/k/l and in order to enter that mode I have to press escape then I again, Is there a quicker way to do that?

like image 431
Helmut Granda Avatar asked Jan 05 '12 21:01

Helmut Granda


2 Answers

I have my escape button mapped to jj.

imap jj <ESC>

That way when I want to enter normal mode fast I double tap jj and my fingers are in a good position to start navigating.

It may seem awkward to begin with but once you get muscle memory it will be like lightening.

like image 171
rogermushroom Avatar answered Sep 28 '22 03:09

rogermushroom


You can temporarily drop out of insert mode by typing ^O to navigate. Useful to get past auto inserted closing brackets.

Most of the time vim understands the page movement buttons if your terminal is known to it. The original vi did not, and this command has always been there.

Useful muscle memory:

^Oo - stop and open line below, capital O is above ^OA - go to the end of the line and carry on inserting ^OI - Start inserting at beginning of line

As an aside:

I used to use vi on system V way back, at least 23 years ago. Personally find the idea of vi having a philosophy very funny. It was a pragmatic replacement for ex written by a lone coder in a hurry. Its pragmatism is why it survived because it was easy to port to any Unix. To get the best you should learn how to use f, t, comma and semicolon - they can save you a lot of effort when you use them with c.

like image 29
Ghoti Avatar answered Sep 28 '22 04:09

Ghoti