9

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?

Ben Brocka
  • 2,006
  • 4
  • 34
  • 53
Helmut Granda
  • 4,565
  • 7
  • 35
  • 51
  • 2
    One 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
  • 1
    possible 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 Answers6

11

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.

rogermushroom
  • 5,486
  • 4
  • 42
  • 68
7

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.

Ghoti
  • 2,388
  • 1
  • 18
  • 22
  • 2
    I 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
2

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-[."

David Lam
  • 4,689
  • 3
  • 23
  • 34
2

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.

user1964269
  • 106
  • 2
1

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.

yarn
  • 89
  • 3
0

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
Community
  • 1
  • 1
rossijonas
  • 183
  • 1
  • 10