Pavel Shevaev wrote:
Hi folks!

AFAIK usage of arrow keys in vim should be avoided at all costs since
h/j/k/l allows one to be more efficient in command mode. But how about
insert mode? Should one avoid using arrow keys in insert mode as well
and switch to command mode and then back to insert mode instead?


There is no "at all costs", no dogma in Vim (except maybe about not running the shell in a window). Some people have been taught dactylography from tachers who would severely punish them if they moved their hands, and they still feel guilty if they do. hjkl is for them. Others have learnt it by themselves, maybe after taking piano lessons, and they are still able to move their hands. If they prefer to use arrow keys, why not? Vim often has several different ways of achieving the same goal: use whatever works best for you.

Since I use 'wrap' and some of my file have very long lines, I have taken advantage of the ":map" command to remap the up and down arrow keys to move by "screen" lines, leaving jk to move by "file" lines, as follows:

map     <Up>      gk
map     <Down>    gj
if exists("*pumvisible")
        inoremap <expr> <Down>  pumvisible() ? "\<lt>Down>" : "\<lt>C-O>gj"
        inoremap <expr> <Up>    pumvisible() ? "\<lt>Up>"   : "\<lt>C-O>gk"
else
        inoremap        <Down>  <C-O>gj
        inoremap        <Up>    <C-O>gk
endif

Now they aren't synonymous anymore, and I use jk (in Normal/Visual mode only, or prefixed by Ctrl-O in Insert mode) or <Up> <Down> (in Normal/Visual or Insert/Replace modes) according to where I want to go.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
49. You never have to deal with busy signals when calling your ISP...because
    you never log off.

Reply via email to