6 ms·
Vim - Putting arrows to use
- lucian1900 14y agoI use arrow keys for movement all the time. Not always, but I found no value in forcing myself otherwise.
- mmozuras 14y agoInteresting. How long have you been using Vim?
- ibotty 14y agoyou 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.
- deleted 14y ago[deleted]
- latortuga 14y agoPage 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 :)
- ibotty 14y agoah 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.)
- lucian1900 14y agoAround 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.
- qu4z-2 14y agoInsert is not a mode. Well, technically it is. But don't think of it as one.
- possibilistic 14y agoYou 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.
- johncoltrane 14y agoVim allows us to use arrows so using the arrows is "right".
- fiona 14y agoCool 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.
- nathan_long 14y agoNot 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.
- mmozuras 14y agoGood 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.
- marcrosoft 14y agoI 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>
- mmozuras 14y agoThat's useful indeed - I have both kj and jk mapped to Esc in my vimrc. https://github.com/mmozuras/vimfiles/blob/master/vimrc#L75 https://github.com/mmozuras/vimfiles/blob/master/vimrc#L75
- pilgrim689 14y agoInteresting, I always did jj, but kj or jk feels speedier. Thanks for the tip!
- rednum 14y agoIt'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?
- ibotty 14y agoi 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.
- mmozuras 14y agoI got used to better ways to navigate in Vim - RegEx pointed out quite a few of them - http://news.ycombinator.com/item?id=4414502 http://news.ycombinator.com/item?id=4414502. I would especially emphasize f,F,t,T and w,W,b,B,e,E.
- samdk 14y agoI 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.)
- RegEx 14y agoI 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 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.
- ibotty 14y agozz is nice. but i hardly need it with set scrolloff=5 with which i always have 5 lines context below and above the cursor.
- RegEx 14y agoI 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.
- johncoltrane 14y agoSame experience here. I have set it to 4 since one year: it's perfect.
- amadeus 14y agoEven 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 https://github.com/Lokaltog/vim-easymotion
- kondro 14y agoMy 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.
- jwpeddle 14y agoI 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.
- artursapek 14y agoFrom 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)
- asb 14y agoI 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 http://www.vim.org/scripts/script.php?script_id=1664
- aartur 14y agoI'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.
- qu4z-2 14y agoIn 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)
- trtg 14y agoA 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.