On Tue, Jul 31, 2012 at 02:58:55PM EDT, Daan wrote: > I've been learning Vim for a while, and one situation has been coming > up a lot for me: > > 1) I'm scrolling through a sourcefile, and see an interesting word I'd > like to edit or yank. 2) I look left at the line number of the word, > and type [line number]G 3) I keep pressing w/W/b/B until I reach the > word, (except if the word happens to be the first or last word of the > line, or located near a unique symbol) > > However, this feels inefficient (especially step 2), and I'm hoping to > find a better solution. > > Some things I think might be possible, but have no experience with: > - Use H/M/L to move roughly to the line, then 0/gm/$ to move roughly > to the column, then using small motions to get to the final spot. > - Learn to guess [number]j/h/k/l way better (perhaps with relative > line numbers) to do something like "7j33l". - Use / and type > characters until it matches, then press enter. - Use the easy motion > plugin. > > Please comment on the above¹ or share your method. :)
I tend to use ‘/’ or ‘?’ extensively for cursor navigation beyond the current line and possibly a couple of lines just before or just after it.. if I use the same trick all the time, there's hope yet I might get good at it. ;-) What I do when I aim for the word ‘world’ in ‘hello world’, that I may have spotted somewhere on my screen, is to search not for ‘hello’ or ‘world’ but rather ‘lo wo’, which appears to be less likely to match as often as either ‘hello’ or ‘world’..² I have no formal explanation... but I noticed that it almost invariably weeds out a significant number of false positives.. at least in the context of the stuff I usually edit. I haven't bothered to look into it but a possible improvement might be to use a mapping and/or a function that would cause the cursor to move three columns to the right so it ends up right on top of the second word automatically. I'd rather be flexible.. Otherwise, when the target word starts in column 1 or is at the end of the line.. or follows a <Tab>, I tend to prefer using a simple regex with the usual anchors (^/$) or \t. I prefer sticking to these two related techniques for ‘long jumps’ rather than mixing in others - e.g. line numbers and such. All in all I think it makes me more efficient.. CJ ¹ Well, effectively moving moving the cursor is not trivial: it's half of the job of editing..! ² Note, that I touch-type and am therefore fairly quick at typing any sequence of letters that happens to be under my eyes without the least overhead.. And also, as a human.. I have kinda gotten used to spotting sequences of two letters+space(s)+two letters that are fairly unlikely to occur in other spots.. I don't always do it ‘by the book’.. caveat emptor.. -- Oh My God!!! Larry is back! -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
