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?
-
2One of the general tenants of vim is to not navigate in insert mode. It's common to map caps lock to ESC to make it easier to exit insert mode. Another general vim tenant is to be in insert mode as little as possible. – Matt Greer Jan 05 '12 at 21:22
-
Please see "Misconception #1" at http://www.viemu.com/a-why-vi-vim.html – Greg Hewgill Jan 05 '12 at 21:27
-
I think you just should train the muscle memory =) – ck3g Jan 05 '12 at 21:57
-
what do you mean ck3g? do you mean just train it to use the ESC key? – Helmut Granda Jan 05 '12 at 22:19
-
1possible duplicate of [Vim: Traversing text in Insert mode](http://stackoverflow.com/questions/1737163/vim-traversing-text-in-insert-mode) – Andreas Grech Apr 22 '13 at 08:16
6 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.

- 5,486
- 4
- 42
- 68
-
3
-
Yes that is correct, it's very rare the 2 letters are required together but when they are I have to press slow – rogermushroom Jan 05 '12 at 21:27
-
I do have jj already mapped, I guess I didnt think about it much. Also I found this answer which helps even further: http://stackoverflow.com/questions/1737163/vim-traversing-text-in-insert-mode – Helmut Granda Jan 05 '12 at 21:30
-
it would be better if you prepend it with your desired mapleader :) inoremap
jj – chanHXC Aug 08 '13 at 13:05 -
1Perhaps but it then requires an extra click everytime you use it just to resolve a problem which occurs very rarely. – rogermushroom Aug 08 '13 at 17:59
-
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.

- 2,388
- 1
- 18
- 22
-
2I was doing the same thing to skip over close brackets until I found out that typing the closed bracket itself will just take me over it without inserting a new one, very useful! – maxymoo Mar 21 '17 at 22:22
use CTRL-[
here's a suggestion (probably from Bram) in the insert.txt helpfile for :h i_CTRL-[
"Note: If your key is hard to hit on your keyboard, train yourself to use CTRL-[."

- 4,689
- 3
- 23
- 34
You can use Ctrl
+C
to exit from the insert mode. Adding things to your vimrc file has a caveat: they don't work if you're on a remote server.

- 106
- 2
If you have a line in your vimrc file that looks like set term=ansi
, comment it out. Once I did that I was able to navigate insert mode with arrow keys no problem.

- 89
- 3
If you want to move more than ONE or TWO positions...
...the best choice is to hit ESC
, move around, and get back to insert mode again.
There's no point on create mappings like <C-h>
to move left and then start hitting it too many times... as a vim user you're not supposed to hit the same key multiple times to achieve a smart movement.
(If the ESC
key isn't close to your fingers, it would be a good option to create a mapping for it.)
If you want to move ONE or TWO posistions on insert mode...
...a good choice would be to define some movements using your <Leader>
key:
(I use ,
as <Leader>
key since it's feels close and confortable to my fingers)
noremap! <Leader>h <left> "move cursor left
noremap! <Leader>j <down> "move cursor down
noremap! <Leader>k <up> "move cursor up
noremap! <Leader>l <right> "move cursor right
noremap! <Leader>w <esc>wi "move one word forward
noremap! <Leader>e <esc>ei "move forward to the end of word
noremap! <Leader>b <esc>bi "move one word backward

- 1
- 1

- 183
- 1
- 10