It’s accepted among Vim users - arrow keys should be avoided at all possible cost. Using hjkl is preferred and is advantageous. You never have to leave the home row - that let’s you be faster and it’s more comfortable for your hands. As someone who’s already had to deal with a little bit of wrist pain, not having to move my hands to arrow keys (and don’t get me started about the mouse) is favorable, to say the least.
It’s not something you get used to immediately though. When I started using Vim, trying to not touch those alluring arrow keys was pretty hard. There’s a way to make it easier, and something I’ve seen in other peoples vimrc - just remap arrow keys to do absolutely nothing:
noremap <Up> <Nop> noremap <Down> <Nop> noremap <Left> <Nop> noremap <Right> <Nop>
I found it very useful. But instead of just disabling, why not map arrow keys to do something useful? I currently have them mapped to text moving. In normal mode, arrows move current line in any direction. In visual mode, selected text gets moved. Let’s start with moving text left and right in normal mode:
nmap <Left> << nmap <Right> >>
Not much to explain here. This maps your
Right keys to the same thing that
>> do. Which is - just move text to left or right. The same for visual mode looks a bit different:
vmap <Left> <gv vmap <Right> >gv
In visual mode, selected areas get moved with
>. There is one problem though. After area gets moved, it gets deselected. It’s solved easily with
gv command. It reselects the last visual area.
That takes care of moving text left and right. What about up and down?
nmap <Up> [e nmap <Down> ]e vmap <Up> [egv vmap <Down> ]egv
This is just one example you can map your arrows to. There are other alternatives. For example, navigating splits:
nnoremap <Right> <C-w>l nnoremap <Left> <C-w>h nnoremap <Up> <C-w>k nnoremap <Down> <C-w>j
I just might remap
hjkl to split navigation, because I use
hjkl less and less, favoring navigating in other ways. Sounds crazy, I know ;)
You can check out my
vimfiles on GitHub. Would love to hear your thoughts on arrows and
hjkl usage in Vim.