Wikia

Vim Tips Wiki

Use ijkl to move the cursor and h to insert

Talk0
1,613pages on
this wiki
Tip 1334 Printable Monobook Previous Next

created 2006 · complexity basic · version 6.0


Like probably many people, I have the "inverse T" cursor key layout deeply etched in muscle memory, and I much prefer this to having left, down, up, right in a row like hjkl is (although I'm sure others prefer having all the keys on the home row). As a result I use ijkl to move the cursor and h to insert (this also means that touch typists get to keep their fingers on the touchtyping home keys and just move their second finger to i when they move the cursor up). This is what the relevant part of my vimrc file looks like:

" remap h to insert and use ijkl for inverse T cursor movement
map h <insert>
map i <Up>
map j <Left>
map k <Down>

CommentsEdit

  • The above example does the job, but hides some functionality. For example, you won't be able do delete "inner word" text object with 'diw' combination, because 'di' will act like 'd<Up>' thus deleting one row before cursor. The simple workaround is to add
ounmap i
ounmap h

after previous strings to .vimrc. This will allow you to continue to use commands with 'i' in the middle. Butt you still can't, for example, select "inner word" in visual mode, cuz pressing 'iw' will move one row up and one word forward.

Another(and imo better) solution is to swap i and h:

map i <Up>
map j <Left>
map k <Down>
noremap h i

This allows to use all operations replacing i with h. E.g., to delete "inner word" pres 'dhw'.

  • You might as well want to use the gmail convention:
j <UP>
k <DOWN>
n <LEFT>
p <RIGHT>

Of course with re-mapping the n and o key functions.


Around Wikia's network

Random Wiki