7 ms·
Put this in your .vimrc: " Disable arrow keys noremap <Up> <nop> noremap <Down> <nop> noremap <Left> <nop> noremap <Right> <nop> You'll have one or
by anonymouz 14y ago
Put this in your .vimrc:
" Disable arrow keys
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
You'll have one or two frustrating days, but after that your muscle memory will take care of remembering "hjkl" for you.
- sdoering 14y agoI know, did this at home and started yelling at my laptop shortly after. Got better, am using the keys nowadays, when using vim. But non the less, the logic didn't register with me. (something like clockwise/counter-clockwise, or anything remotely recognizable ;-) )
- martinp 14y agoAnother vote for this method. This is the only way I managed to train myself to use hjkl when I first started learning Vim. I also disabled Home, End, PgUp and PgDown: noremap <home> <nop> noremap <end> <nop> noremap <pageup> <nop> noremap <pagedown> <nop>
- koralatov 14y agoDuly added to my .vimrc, just in case. Cheers!
- SiVal 14y agoEvery keyboard now has a set of hardware arrowkeys sensibly arranged in an inverted-T, where up means up, left means left, etc. Since everyone is used to that arrangement without any mental effort, macho vim types tell you to force yourself to write with your feet basically to show how hardcore you are. They tell you to use your customization ability in .vimrc to block the sensible arrangement in order to force yourself to learn a ridiculous one that has no advantage other than being the one that we old-timers had to learn before there were sensible arrowkeys. I used that arrangement back in the 1980s myself, but when keyboards evolved, so did I. I remapped the movement keys to match the other movement keys (arrowkeys). If you're going to go to the effort of customizing your vim to force yourself to learn a new keyboard arrangement, customize it so that the movement keys are ijkl instead of hjkl, so that both of your sets of arrowkeys are in the same, natural, modern, inverted-T arrangement. Then you don't have to deactivate those real arrowkeys, because there won't be any temptation to use them with the ijkl keys in the same arrangement and easier to reach. "Oh, no!" people half my age will shriek. "Then what happens to the 'i' key? This would be impossible." Just use the now-unused key on the left ('h') for your insert-on-left. Reach left to insert on left. There, easy. Funny how those who insist that YOU should relearn something as fundamental as the entire inverted-T arrowkey structure built into the hardware of every keyboard and used by almost all apps on all platforms including kids' game boxes find relearning a single, arbitrary 'i' key such an insurmountable obstacle to themselves. But what if you have to use a copy of vim on a machine without your customized .vimrc? Sorry, but that's just an argument against ANY useful customization of vim. It's just not a problem, because the real arrowkeys on the keyboard are in the arrangement you're used to using on the ijkl keys. Just use the real arrowkeys temporarily or copy over your .vimrc. I've done it for years. But what about other editors that have a vi mode? What about something like zsh with a vi mode? These things can be remapped to match your .vimrc unless they only offer a couple of keys, in which case they can be treated just like all apps with their own couple of local keyboard shortcuts. Really, if the standard advice is, "You'll have one or two frustrating days, but after that your muscle memory will take care of remembering "hjkl" for you," then you can take your own advice and keep the inverted-T muscle memory you already have for the movement keys and reduce your task to learning a single 'h' key for insertion, and save the next generation from this nonsense. If a 30-yr user of vi like me isn't stuck with the historical accidents of the past, why should new users have to be?
- arethuza 14y ago"Every keyboard now has a set of hardware arrowkeys sensibly arranged in an inverted-T" I've never got into the habit of using anything other than arrow keys even though I've been an occasional vi user for 26 years. Indeed the ancient model of TeleVideo terminal I first learnt Unix on had arrow keys - although not in an inverted-T: http://www.backglass.org/duncan/gimix/gimix_terminal.jpg http://www.backglass.org/duncan/gimix/gimix_terminal.jpg
- anonymouz 14y agoWhat a rant! Unfortunately, it is entirely misguided. Nobody wants to force anyone to use the 'hjkl' arrangement, I was merely sharing a tip on how to get used to it if someone already wants to switch from arrow keys to 'hjkl' (like I did at some point in time). The reason for doing this is, for me, simply that it is on the home row, and therefore I can reach it quicker. If you like 'ijkl', fine, do that. I feel more comfortably with 'hjkl'. Or rather, what I am actually using is 'dhtn', being a Dvorak user. And my delete is on 'e'. Because that is how I like it. Use whatever you like, but in any case switching from one variant to another (for whatever reason) will take a few days of retraining the muscle memory.
- SiVal 14y ago[Your rant is entirely misguided.] Nobody wants to force anyone to use the 'hjkl' arrangement No, instead, they advise all new users that they should force themselves. Why are new vim users so often advised to deactivate their arrowkeys? Apparently the arrowkeys tempt them to take their hands off the normal keys. Why are they so tempted to do something so awkward? Because to new vim users with a lifetime of experience with inverted-T arrangements, the weird, archaic hjkl arrangement is even more awkward. "Well," they're told, "the solution is to make your arrowkeys YET MORE awkward by deactivating them entirely." What I'm saying is that the significant vim benefits that come from staying on the normal keys can be obtained with a carrot instead of a stick. Instead of making their arrowkeys even more difficult than the awkward hjkl keys, make their normal keys even more tempting.
- 14y ago
- nonamegiven 14y agoAlthough this can be helpful to force some people to learn hjkl, you may want to remove this after awhile. I use whatever my hand happens to be closer to. 85% of the time that's the home row, hjkl. But if my hand is closer to the arrow keys I'll use that, and if my hand is on the mouse I'll use that.
- gmrple 14y agoMy preferred method is a couple hours of Nethack.
- oftenwrong 14y agoI re-purposed mine for buffer switching: " Arrow keys set up for easy buffer switching nnoremap <left> :bprev<cr> nnoremap <right> :bnext<cr> nnoremap <down> :buffer #<cr> nnoremap <up> :buffers<cr>:buffer<space>