Tips on what to remap `hjkl` to in normal mode? :D

Yooeddii,

I have become fairly good now at using f and / for searching and so I am wondering if anyone here has remapped hjkl to something fun and useful? I am trying to come up with something smart but it is not as easy as I thought it would be :stuck_out_tongue: If I come up with something good I will edit the post with my solution. Is there anyone here who has remapped hjkl to something else?

Iā€™m not saying donā€™t do this, your vimrc is your vimrc, and who am i to say ā€œdontā€™ change the defaultsā€ā€¦ but I once went down the road of changing frequently used, common defaults and really regretted it later. one reason was that i needed to use embedded vims elsewhere and I could no longer use my muscle memory. I was often enough that it was quite annoying and so i went back to defaults and wondered why i even changed them in the first place. the defaults i changed werenā€™t ā€œless efficientā€ or ā€œharderā€ or some damn thing, i just suck at typing.

however if you do go down this route i would suggest that they still fit the mental model of hjkl i.e. horizontal/vertical. next blank lines (or scope or function) for the vertical movement on j and k, beginning end of line for h and l, would be an example. overloading hjkl and its shift, alt, control modifiers is fairly nice when they all share the same mental model.

1 Like

Thanks, this was a really good answer! I agree, I have to ponder this a bit more to see if it actually makes
sense. In most cases Iā€™ll be able to use my own configs but you have a fair point.

@molleweide I would recommend this. As you donā€™t want to make a conflict between the keys and navigations keys in insert mode
(i.e. when you write ā€œhā€, instead of writing the letter you are going left :rofl: )

NB: The inoremap statements apply to insert mode, while the cnoremap ones apply to command mode

" In insert or command mode, move normally by using Ctrl
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>

hmm this is also quite nice, l have to make sure i am using the binding somehow. atm I am also using kmonad which has allowed me to create a navigation layer on homerow if I hold down .

I know that you can also use Alt-hjkl. Do you know if it is also possible to use , ie.
ctrl and alt together??

<M-n> means Alt-n

inoremap <M-h> <Left>
inoremap <M-j> <Down>
inoremap <M-k> <Up>
inoremap <M-l> <Right>

yes but i meant holding down Ctrl and Alt at the same time so like a tripple key chord :stuck_out_tongue: I see also that I was unclear in my previous reply.

also what have you remapped hjkl to in normal mode?

another way to do alt would be <a-o> which is alt o. I donā€™t think you can do ctrl with other modifiers (you should double check this) but you can use alt and shift together, <a-s-o> would be alt-shift-o. Maybe multiple modifier capability depends on your terminal or something.

1 Like

I use the default config

here you go. <a- also does the job of Alt too

\" In insert or command mode, move normally by using Ctrl + Alt
inoremap <C-M-h> <Left>
inoremap <C-M-j> <Down>
inoremap <C-M-k> <Up>
inoremap <C-M-l> <Right>
cnoremap <C-M-h> <Left>
cnoremap <C-M-j> <Down>
cnoremap <C-M-k> <Up>
cnoremap <C-M-l> <Right>
1 Like