Reputation: 4705
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?
Upvotes: 9
Views: 6016
Reputation: 183
...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.)
...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
Upvotes: 0
Reputation: 2380
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.
Upvotes: 7
Reputation: 89
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.
Upvotes: 1
Reputation: 106
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.
Upvotes: 2
Reputation: 4948
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-[."
Upvotes: 2
Reputation: 5586
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.
Upvotes: 12