Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim remapping the hjkl

Tags:

I am trying to map the letter hjkl to jkl in my .vimrc file so that I can have my fingers the way they always are on the keyboard, while writing in vim.

The problem is that as I map k to l, it jumps into the l to ;. so k becomes the same as ;. The same off course happens to all of them.

So all the keys become one because they copy through one another.

How can I prevent that?

like image 904
john-jones Avatar asked Jun 21 '10 10:06

john-jones


3 Answers

use noremap:

noremap ; l
noremap l k
noremap k j
noremap j h
like image 81
Lie Ryan Avatar answered Oct 19 '22 08:10

Lie Ryan


Check out :help noremap. This will prevent maps from recursively being mapped.

like image 41
Randy Morris Avatar answered Oct 19 '22 08:10

Randy Morris


As a follow-up to @Lie Ryan's comment, I've written this Answer on a similar question

Basically, you might want to consider keeping:

j & k = up & down

since those are so primary

But then also consider:

l & ; = left & right

like image 27
Bukov Avatar answered Oct 19 '22 09:10

Bukov