Linux – How to you switch the j and k keys in vim

keyboard shortcutslinuxterminalvim

Is there any way to map the k key to 'down' and the j key to 'up'? This seems much more intuitive to me, since the right arrow will also move the cursor down, if it's at the end of the line.

Why was this mapping decided on? And why does the left / right movement not also take you to the next line like in most other editors?

Best Answer

You can do it, but this is a Bad Idea™! This is going to cause you grief down the road.

However, if you are dead set on doing this, put these two lines in ~/.vimrc:

:nnoremap j k
:nnoremap k j

As for left/right moving wrapping on lines:

:set whichwrap+=h,l

See :help 'whichwrap' (with the single-quotes), and note that the help says this is not recommended.