Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ok, I'm going to get a little blasphemous here, but I retain functionality of the arrow keys because they allow me to move the cursor while in INSERT mode. I find that ESC + [hjkl] + I to be slower than just using the arrow keys since the distance to escape vs arrows keys is about the same for the respective fingers (minus the cost of exiting and re-entering INSERT mode). I am sometimes told I should remap ESC to facilitate the use of hjkl, but the benefits seem dubious since I rarely have a need to move one or two spaces/lines outside of INSERT mode (instead, opting to traverse my code via line number, [], g/G, w/b, A/I, or marks).

tl;dr - arrow keys vs hjkl makes little productivity difference to an experienced vim user (unless of course, you've baked hjkl into your workflow, but remember that the reverse is true as well)

edit: I also find it productive to have one mental model for cursor movement as well as selecting splits or tmux panes.



You really shouldn't be moving in insert mode. The only thing you should be doing in insert mode is typing new text (or erasing a few characters immediately before the cursor that you mistyped while still in insert mode).

Once you're outside of insert mode, you have a ton of options for moving around very quickly and efficiently. You are crippling yourself by using the arrow keys to move character by character or line by line instead of going out of insert mode, not to mention the time you waste moving your entire hand to the arrow keys and back.

That said, if you really feel you absolutely must move in insert mode, may I suggest mapping:

  control-h
  control-j
  control-k
  control-l
to move while in insert mode, instead of using the arrow keys. That way your hands can remain on the home row, and you'll continue to use the familiar keys to move around. (As for hitting the control key itself, I like to do that with the part of my palm that's right below my little finger, so I don't have to move my fingers from the home row -- it also makes for virtually no finger strain, compared to using your fingers to hit it).

But you should really try to wean yourself off the bad habit of moving in insert mode.


I find this needlessly strict. Personally I map arrow keys to more useful things in normal mode (tab switching for left/right), but I leave them in insert mode not because I have a bad habit of using them, but because on the occasions that I instinctively use them (eg. I often type pairs of braces and then back-arrow) they are not a crutch preventing me from using some more efficient normal mode ops. I am extremely fluent in hjklwWeEbBfFtT, and I correctly use the atomicity of insert mode, so it would just be dogma if I remapped arrow keys in insert mode.

Also btw, Control-h,j,k,l I have mapped to switch windows.


"But you should really try to wean yourself off the bad habit of moving in insert mode."

That's just dogmatism for the sake of it. There are certainly cases where it takes less finger movement to use arrow key movement (either by character or by word) in insert mode than it would take with switching to normal mode and doing hjkl movement.


I have seven years of professional avg personal daily use of vim and never bothered to leave the arrows. I don't move so often in insert mode, I just prefer my hands the be far from each other. Ijkl maniacs should stop repeating the same refrain over and over...

My favorite tricks: o in select mode, ctrl-y in insert mode.

Still looking for a good commenter for python (NERD commenter don't work for me)


"I have seven years of professional avg personal daily use of vim and never bothered to leave the arrows."

There are also two-finger, hunt-and-peck typists who've been typing for 30 years.

Just because you've been doing something one way for a long time doesn't mean it's a good idea.


Arrow keys are fine in insert mode but it sounds like you might be spending too much time in insert mode rather than considering normal to be the default mode. Do you use arrows in normal mode too?


>I rarely have a need to move one or two spaces/lines outside of INSERT mode (instead, opting to traverse my code via line number, [], g/G, w/b, A/I, or marks).


if you're hopping out of insert mode to do a single navigation command, why not use the insert mode's ^O mapping?

(in insert mode)

  ^O t x
(still in insert mode, and the cursor has navigated to right before the next 'x' character)

  ^O 4 4 G
(still in insert mode, now on line 44)


This isn't an issue if you've mapped ESC to jk or something similar.


<j><k><k><i>

OR

<up>

I prefer a single key to four, even if I have to move my hand off the home-row.


How often is it that you want to perform this move (edit the character immediately above the cursor, but not in block mode)? If you're moving horizontally by a single space, you have backspace and delete for single-character moves (which are an edge case). If you're intending to add new content in a new line, why not <Esc>O?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: