Live data from Hacker News

Vim - Putting arrows to use

codingfearlessly.com

11–20 of 42 posts

Re: Vim - Putting arrows to use

#13

Not to be too cranky, but the rationale for avoiding the arrow keys is to keep your hands on the home row. So anything useful you find to do with them, if you do it often, will be inefficient.

Good point and something I should've written in the post. Text moving is not something needed very often, but I find using arrows in this case more pleasant than <gv or [egv. In normal mode, I'll usually use <<, because I'm already used to it.

Re: Vim - Putting arrows to use

#14

I don't remember where I found it but the best remapping I ever did was to map the sequence 'kj' to esc. kj is rarely used in a word, and when it is it isn't a big deal. inoremap kj

That's useful indeed - I have both kj and jk mapped to Esc in my vimrc.

https://github.com/mmozuras/vimfiles/blob/master/vimrc#L75

Re: Vim - Putting arrows to use

#15
It's a nice idea, but I don't buy it. What I like most about vim is how few unnecesary moves I make with my hands - in particular my wrists stay in the same place all the time; reaching for arrows would require moving the whole forearm, which I don't like and which breaks my flow.

Also I'm curious about this quote from OP:

  I just might remap hjkl to split navigation, 
  because I use hjkl less and less, favoring 
  navigating in other ways. Sounds crazy, I know ;)
Can you elaborate on your habits that cause it?

Re: Vim - Putting arrows to use

#16
post #7

Earlier quoted context omitted.

you did not ask me, but: when i'm busy thinking about the code, when i'm not typing for a long time, i lay back and browse the sourcecode with arrows and (up and down or pg-up and pg-down). not that fast, sure. but can be done with one hand, the other is scratching my head or what helps me think.

Page up and page down are part of my must-learn-asap shortcuts when learning a new editor - once you have hjkl and ctrl+f/ctrl+b ingrained, browsing code while keeping your hands mostly over the home row becomes a lot easier and you don't have to move your hands back and forth. I've found that if I want to browse my code with one hand, the scrollwheel on my mouse does the trick :)

ah yes. mouses. i knew there was another input controller...

(not to be misunderstood, i use mostly hjkl and ctrl-d and ctrl-u (half-screen up and down). and i find the mouse uncomfortable.)

Re: Vim - Putting arrows to use

#17
I use my up/down keys to move between visible lines (rather than real lines, which is what they and j/k do by default). This can be helpful occasionally when you have lines wrapped for something that's text rather than code.

    " up/down move between visual lines
    " instead of actual lines when wrapped
    imap   gj
    imap   gk
    nmap   gj
    nmap   gk
(You could also map j/k to just do this if it's something you use often, but I prefer not to.)

Re: Vim - Putting arrows to use

#18
I believe many VIM users overestimate the importance of using h,j,k,l in comparison to numeric modifiers. Holding down j to scroll down the page is no more "right" than holding down the down arrow, in my opinion.

The following made me considerably faster:

* Relative Line numbering (For Vim 7.3). G/gg stop being convenient for frequent line movement once your file goes beyond 100 lines. Doing math in your head to figure out if line 589 is 16 lines from 605 takes way too much effort. Append this[0] to your ~/.vimrc, and then CTRL-l will toggle relative/absolute line numbering. So in relative mode, you see a line is 20 up from your cursor, and 20k takes you there with no guessing or holding down keys.

[0]: https://gist.github.com/3418841

* Learn the following: f,F,t,T. Combine them with c and d.

* zz => make current line appear in middle of the screen.

* H,L,M

* w,W,b,B. Combine with numeric modifiers (5dW)

* CTRL-u, CTRL-d, CTRL-f, CTRL-b

* % for block highlighting. Works well with curly braces by default, you may need to pick up extra plugins for ruby/python.

* g; will cycle back to the last places you were in insert mode. g, will cycle forward.

Re: Vim - Putting arrows to use

#19
post #15

It's a nice idea, but I don't buy it. What I like most about vim is how few unnecesary moves I make with my hands - in particular my wrists stay in the same place all the time; reaching for arrows would require moving the whole forearm, which I don't like and which breaks my flow. Also I'm curious about this quote from OP: I just might remap hjkl to split navigation, because I use hjkl less and less, favoring navigat…

i have not been asked, but there are so many nice movements, that i hardly use hl. these might as well be remapped. i value k and l very much though.

Re: Vim - Putting arrows to use

#20
post #18

I believe many VIM users overestimate the importance of using h,j,k,l in comparison to numeric modifiers. Holding down j to scroll down the page is no more "right" than holding down the down arrow, in my opinion. The following made me considerably faster: * Relative Line numbering (For Vim 7.3). G/gg stop being convenient for frequent line movement once your file goes beyond 100 lines. Doing math in your head to figu…

zz is nice. but i hardly need it with

set scrolloff=5

with which i always have 5 lines context below and above the cursor.

Post reply on HN