News for hackers. Stuff that matters.
Re:Vim - Putting arrows to use by RegEx on Tuesday August 21, 2012 @04:04PM (#4414502)
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 by amadeus on Tuesday August 21, 2012 @04:42PM (#4414681)
Even better, just learn to use EasyMotion, it's one of the most efficient ways of navigating around a file:

https://github.com/Lokaltog/vim-easymotion

Re:Vim - Putting arrows to use by johncoltrane on Tuesday August 21, 2012 @05:18PM (#4414831)
I've tried it and didn't like it at all.

The main problem is how it replaces the letter I'm searching with another unrelated one, making all the matches practically unreadable. To me, at least.

    set incsearch
and

    /foo
    ?bar
are more than enough for my needs.
Re:Vim - Putting arrows to use by dedward on Tuesday August 21, 2012 @07:32PM (#4415342)
EasyMotion is really only good for getting to something you are staring right at on the screen.... I want to go THERE.. not meant as a general search or anything like that... and doesn't help get off the screen, for sure.
Re:Vim - Putting arrows to use by amadeus on Wednesday August 22, 2012 @11:57AM (#4417980)
Basically what dedward said before me.

EasyMotion is not for searching, it's for moving the cursor deliberately to a place onscreen where you need to make an edit.

Re:Vim - Putting arrows to use by johncoltrane on Wednesday August 22, 2012 @01:04PM (#4418337)
Yes, I know.

Searching is how I move to where I want.

It's a lot less confusing to me than EasyMotion's logic, it's consistent whether the word I want to jump to is visible or not and it's a native feature.

Well, I was curious when it was released so I've used it for a couple of weeks and found it horrible and confusing. Obviously many people like it so let's say it's a matter of taste.

Re:Vim - Putting arrows to use by ninetax on Tuesday August 21, 2012 @06:13PM (#4415083)
I have been playing with the relative numbering all afternoon. I love having all my lines indexed, but it's hard to hit any number above 5 or 6 with my right hand because it's about to hit j or k. I wish it could be indexed with a combination of numbers between 1 and 5 only, but I guess that would mess with the j and k functionality.

Any ideas?

Also note: I am not a touch typist.

Re:Vim - Putting arrows to use by RegEx on Tuesday August 21, 2012 @06:38PM (#4415160)
I don't use anything beyond 5(with the exception of 0 because that's fairly easy for me to hit). 6 and 7 are the hardest to hit. 17k for me just becomes 15kkk, for example. If you ever find yourself needing to go 50+ up or down, you should be using one of H, L, or M to take out a good chunk of that.
Re:Vim - Putting arrows to use by ninetax on Tuesday August 21, 2012 @06:44PM (#4415178)
Yeah that's what I was thinking. Thanks!
Re:Vim - Putting arrows to use by ibotty on Tuesday August 21, 2012 @04:11PM (#4414536)
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.

Re:Vim - Putting arrows to use by RegEx on Tuesday August 21, 2012 @04:28PM (#4414620)
I had tried scrolloff=1000 for middle scrolling. I liked it for a while, but got a little tired of the jumpy-ness. I'll give 5 a go.
Re:Vim - Putting arrows to use by johncoltrane on Tuesday August 21, 2012 @05:19PM (#4414836)
Same experience here. I have set it to 4 since one year: it's perfect.
Re:Vim - Putting arrows to use by samdk on Tuesday August 21, 2012 @04:04PM (#4414499)
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 <silent> <Down> <C-o>gj
    imap <silent> <Up> <C-o>gk
    nmap <silent> <Down> gj
    nmap <silent> <Up> 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 by marcrosoft on Tuesday August 21, 2012 @03:56PM (#4414451)
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 <Esc>

Re:Vim - Putting arrows to use by mmozuras on Tuesday August 21, 2012 @04:01PM (#4414485)
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 by pilgrim689 on Tuesday August 21, 2012 @06:02PM (#4415042)
Interesting, I always did jj, but kj or jk feels speedier. Thanks for the tip!
Re:Vim - Putting arrows to use by lucian1900 on Tuesday August 21, 2012 @03:24PM (#4414286)
I use arrow keys for movement all the time. Not always, but I found no value in forcing myself otherwise.
Re:Vim - Putting arrows to use by mmozuras on Tuesday August 21, 2012 @03:28PM (#4414299)
Interesting. How long have you been using Vim?
Re:Vim - Putting arrows to use by ibotty on Tuesday August 21, 2012 @03:40PM (#4414365)
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.
Re:Vim - Putting arrows to use by latortuga on Tuesday August 21, 2012 @03:45PM (#4414394)
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 :)
Re:Vim - Putting arrows to use by ibotty on Tuesday August 21, 2012 @04:04PM (#4414497)
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 by lucian1900 on Wednesday August 22, 2012 @04:00AM (#4416447)
Around 2 years I think.

Often switching mode to move around is just more effort than moving my hand a little, at least on the laptops I've used lately.

Re:Vim - Putting arrows to use by qu4z-2 on Friday August 24, 2012 @02:58AM (#4426547)
Insert is not a mode.

Well, technically it is. But don't think of it as one.

Re:Vim - Putting arrows to use by possibilistic on Tuesday August 21, 2012 @03:31PM (#4414321)
You do use hjkl and the others, right? As long as you do, we're good here. But if not, you need to block the arrow keys and use vim the 'right way'. I assume what you must mean is that you are using these in insert mode. Simply don't. Drop out of insert mode for navigation concerns and let vim handle the heavy movement work.
Re:Vim - Putting arrows to use by johncoltrane on Tuesday August 21, 2012 @05:23PM (#4414852)
Vim allows us to use arrows so using the arrows is "right".
Re:Vim - Putting arrows to use by kondro on Tuesday August 21, 2012 @05:29PM (#4414890)
My issue has always been one of muscle memory.

The hjkl keys are fine to use when in Vim, but the majority of other products (browsers, word processors, spreadsheets, etc) don't support them for movement. So I have a constant context-switch in my muscle memory when moving between these different applications.

On a Mac keyboard, I find arrow-key navigation with my pinky finger very efficient… only requiring the rest of my fingers to move from the home row when pressing right.

I'm not sure this would work for everyone… but for me, one set of muscle memory is superior to convincing my nervous system to context-switch.

Re:Vim - Putting arrows to use by nathan_long on Tuesday August 21, 2012 @03:53PM (#4414440)
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.
Re:Vim - Putting arrows to use by mmozuras on Tuesday August 21, 2012 @04:00PM (#4414472)
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 by rednum on Tuesday August 21, 2012 @04:02PM (#4414492)
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 by mmozuras on Tuesday August 21, 2012 @04:12PM (#4414545)
I got used to better ways to navigate in Vim - RegEx pointed out quite a few of them - http://news.ycombinator.com/item?id=4414502. I would especially emphasize f,F,t,T and w,W,b,B,e,E.
Re:Vim - Putting arrows to use by ibotty on Tuesday August 21, 2012 @04:08PM (#4414520)
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 by aartur on Tuesday August 21, 2012 @06:12PM (#4415081)
I'm a rather advanced Vim user (10 years, vimrc with custom vimscript, use many shortcuts for movement), but I find it unproductive to NOT use arrows in insert mode. Example: inserting 'x' two characters before current position.

With arrows: <LEFT><LEFT>x<RIGHT>

Without arrows: <ESC>hix<ESC>lli

It also much depends on a keyboard design, the laptop-like often have arrows under ENTER and using them doesn't require hand movement.

Re:Vim - Putting arrows to use by qu4z-2 on Friday August 24, 2012 @03:23AM (#4426612)
In that situation I'd likely as not just backspace to the offending location and continue typing. Although I have been known to map caps+hjkl to the arrow keys.

(I'm assuming your situation is a typo while you're inserting a short string, rather than just defaulting to insert mode)

Re:Vim - Putting arrows to use by fiona on Tuesday August 21, 2012 @03:26PM (#4414294)
Cool idea. I read an article here a couple months ago about vim autocomplete and I mapped my tab key to autocomplete, but that was super annoying for, you know, adding indentation.

Now I've got my arrow keys mapped to Nop in all modes except I mapped my right key to autocomplete in insert mode, which has worked pretty well for the last 10 minutes. I'd really like to start using autocomplete more, so for me it's handier than text moving.

Re:Vim - Putting arrows to use by RegEx on Tuesday August 21, 2012 @03:32PM (#4414327)
Check this[0] out. Autocomplete when typing words, indentation otherwise.

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

Re:Vim - Putting arrows to use by fiona on Tuesday August 21, 2012 @03:47PM (#4414406)
thanks, that's a way better solution.
Re:Vim - Putting arrows to use by trtg on Tuesday August 21, 2012 @06:53PM (#4415207)
A very small corner case here, but on certain keyboard layouts, hjkl is actually harder to use than the arrow keys. To be more specific, I use an alphagrip keyboard most of the time where left,right,up,down are all under the left thumb and a trackball is under the right thumb. The way I interact with vim is thus very different from most folks, I imagine.
Re:Vim - Putting arrows to use by asb on Tuesday August 21, 2012 @05:55PM (#4415008)
I prefer to map left and right arrow to navigate :bprev and :bnext. Paired with buftabs, I find it rather handy http://www.vim.org/scripts/script.php?script_id=1664
Re:Vim - Putting arrows to use by artursapek on Tuesday August 21, 2012 @05:41PM (#4414945)
From my funny looking vimrc: navigating between splits with Alt+HJKL

    nnoremap ¬ <C-w>l
    nnoremap ˙ <C-w>h
    nnoremap ˚ <C-w>k
    nnoremap ∆ <C-w>j
(Mac :P)
Re:Vim - Putting arrows to use by jwpeddle on Tuesday August 21, 2012 @05:41PM (#4414944)
I map left/right to next/previous tab, and up/down to next/previous buffer, since if I switch files my hand is often coming from the mouse and the arrows are along the way.