3 ms·
This is a great resource, but the article is pretty strict on the arrow keys. I would recommend `nnoremap`, over `noremap`, because it only disabled the arrow k
by yes_or_gnome 10y ago
This is a great resource, but the article is pretty strict on the arrow keys. I would recommend `nnoremap`, over `noremap`, because it only disabled the arrow keys in Normal Mode.
The author's explains his rationale in the next section, it's to prevent users from living in Insert Mode. Fair enough. But, when making several relatively close edits, the ability to tap a few arrow keys in Insert Mode is far easier and less mentally demanding than any key combination that requires the user to bounce around different modes.
- DSMan195276 10y agoI don't really disagree with your overall point, the arrows keys are not horrible, but I think for beginners removing all arrow keys is the best approach. I used vim for a while just relying on the arrow keys, and it wasn't until I disabled them completely that I really started to use vim. If I left them on in insert mode, I would have just ended up using them that way, just due to muscle memory. I'd also add that if you remap Esc to something more manageable, leaving insert mode for a second to move around starts feeling a lot more natural. I still do get where you're coming from, the arrow keys do have a time and place. But since I do all of my moving around in normal mode, leaving insert mode to do it just 'makes sense' now and I really don't even have to think about it.
- yes_or_gnome 10y agoAbsolutely agree. I completely disabled arrow keys for a short time; ~3 months. It started out after reading a similar recommendation. It was difficult for a few days, but then I completely forgot about my arrow keys and the fact that I disabled them. It wasn't until months later that I was in one of these situations that I wanted to use the arrow keys, but they didn't work. Which was confusing. This must have been around the time that I started to understand, and manicure, my vimrc because I remember having to learn all the mapping modes to recover arrow keys for Insert Mode. So, anecdotally, completely disabling arrow keys led me to learn more Vim than just efficient movement. Today, though, I don't have the makings anymore because it's no longer a problem. One quick question; I can't answer this because I am currently commuting. Does 'noremap' disable keys in Command Mode? Now, that would be aggregating, to me. Also, there a remap mode that combines Normal and Visual modes (right?), that would be one better than 'nnoremap'.
- rectang 10y agoI tried and failed to make myself use `hjkl` instead of the arrow keys. It was a perpetual hindrance to my brain that up (`k`) and down (`j`) did not spatially reinforce their functions. What ultimately worked was to map the triangle `ijkl` like you normally see `wasd` in games. i jkl i -- up k -- down j -- left l -- right I then added two more keys beyond left and right to skip forward and back by words. i hjkl; h -- skip backward to the beginning of a word (ordinarily `b`) ; -- skip forward to the end of a word (ordinarily `e`) There were some echo effects since I had to replace `i`, but they were manageable. On machines where I don't have my vimrc available I'm still functional, just clumsy. It was definitely worth it. My vimrc: https://github.com/rectang/dotfiles/blob/master/vimextra https://github.com/rectang/dotfiles/blob/master/vimextra
- Lxr 10y agoOh god... doesn't this mess with plugins or something?
- vadskye 10y agoSpeaking as someone with a similar setup, I've never had many issues with plugins assuming the use of hjkl. The only one I can think of offhand that has issues is indent-object. The thing that really causes issues is my attempt to swap the roles of [ and {, using [] to jump between paragraphs and {} to do fancy function jumping. Vim plugins really don't like that...
- vadskye 10y agoSomeone else has found the wisdom of ijkl! :D My setup uses "u" and "o" the same way you use "h" and ";". I also extended it so you can use modifiers on I and K to get page up/page down behavior, or to navigate between indentation levels.
- godshatter 10y agoI've tried not using the arrow keys, but my problem is that I use the dvorak layout at home, and typing jcvp to maneuver around (what hjkl maps to) confuses me too much. Especially since I use vim at work as well on the normal qwerty layout. Maybe I'll try again soon. In the meantime, I'll try to incorporate *, #, and gi into my muscle memory (for both layouts). The dvorak layout (and especially switching layouts) saved me from a lot of pain, so I don't plan on ditching it any time soon.
- dota_fanatic 10y agoOr, get a keyboard that allows for the thumbs to be used for more than just the spacebar! :) Something like this: https://ergodox-ez.com/collections/frontpage/products/ergodox-ez-bundle-with-printed-keycaps https://ergodox-ez.com/collections/frontpage/products/ergodo...
- grault 10y agoPersonally, I NOP-ed all arrow keys _and_ hjkl also, after I found myself keeping j pressed to get to an area at the bottom of the window. Which would be an L. Then NOP-ed, bit by bit, many other things which could be done faster. 90% of my movements are search, BWtf{} and some scrolling with zt zz zb. The only case I found the lack of hjkl problematic so far is in block visual mode. Another anti-pattern I did was Da and dWi, NOP-ed them and forced myself to start using C and cW respectively. Not much of an achievement, but feels better :) Same for x, I deleted whole words with x, then pressed i, I removed the mapping of x. Conclusion: in case you think you have an anti-pattern, just NOP the mappings. In case one or two turns out to be too much of restriction, you could always remove the NOP mapping later.
- oinksoft 10y agoEither way, mapping the arrow keys to <nop> seems wasteful. In normal mode I map up/down to :cprevious/:cnext and left/right to :colder/:cnewer, which makes error list navigation effortless. Some other good targets are the buffer, tag and location lists (with a little work you could make them context-aware too). I don't remap the arrow keys in insert mode though, it'd be annoying to have to exit insert mode only to move the cursor a few characters.