4 ms·
Author of the article here; never thought I'd be posting HN-worthy content, otherwise I would've picked something other than a very wimpy (but cheap) Xen VPS ho
by dnquark 15y ago
Author of the article here; never thought I'd be posting HN-worthy content, otherwise I would've picked something other than a very wimpy (but cheap) Xen VPS host (which I can't even SSH into at the moment)... For Emacs users, here's the alternative to Google cache -- the original org-mode file of the post (I use org2blog): http://dl.dropbox.com/u/2685883/evil.org http://dl.dropbox.com/u/2685883/evil.org
(Alternatively, here's the text posted on Google+:
https://plus.google.com/105073748129411089493/posts/7xEUhCohT1H https://plus.google.com/105073748129411089493/posts/7xEUhCoh...)
For all the Vim/Evil users here, I have a question (something that I didn't get around to mentioning in my blog post): what are the standard ways in Vim to navigate code in syntactic units? The s-expression motions in Emacs are very handy: for instance, if I am at the end of the line and I want to select foo(bar), I just do C-M-b a couple of times; likewise, if the point is before "foo", I do C-M-f. In Evil, if the point is before "foo", % works well, but not if the point is at e.o.l. That's currently one of my biggest gripes with Evil.
- mattbriggs 15y agoI actually use a whole bunch of things for motion. backward-sexp is really nice, but very lisp specific, and I only rarely get to hack on lisp stuff. I use a combination of the following to jump around, and rarely find things lacking. My exact bindings probably break common emacs-isms and would be sacrilege to a true emacsen, but they work well for me :) If the cursor is more then a few lines away, i will use / to search (or ? to back search) and then n my way to the target. If I am on the same line, I will use f<target char> . that will move the cursor to be on the the next occurance of that character, and semi-colon repeats the motion. so given the quick brown fox jumps over the lazy dog if the cursor is at the start of the line and i want to get to the o in over, I would type "fo;;" seems a bit verbose, but ; is easy to hit, and sort of a twitch motion, so it is actually pretty natural. If the place I want to get to is close to the beginning or ending of the line, i have ^(go to first non whitespace char) mapped to H, and $(go to end of line) mapped to L. given the vim hjkl bindings, HL is very easy to hit. If I am more just "cruising" through the file, i have c-h mapped to b (back a word) and c-l mapped to w (forward word), and c-j to } (next paragraph) c-k (prev paragraph). So holding down ctrl puts me into "move quickly mode" If I am close to a paren, I have % mapped to <space><space>, but that is mostly situational (i find I use it most often in lispy languages) If I am on a word and want to move to another occurance of the same word, I usually use * and n my way to where I want to be (although I also use highlight-symbol.el with m-n m-p mapped to next/prev occurance) Finally, something I just started trying out is jaunte.el. Done by a japanese guy, but if you look at the screencap here http://translate.google.com/translate?hl=en&sl=ja&u=http://kawaguchi.posterous.com/emacshit-a-hint&ei=Uc5JT-bVKczOgAfK2umbDg&sa=X&oi=translate&ct=result&resnum=1&ved=0CCMQ7gEwAA&prev=/search%3Fq%3Djaunte.el%26hl%3Den%26biw%3D1517%26bih%3D726%26prmd%3Dimvns http://translate.google.com/translate?hl=en&sl=ja&u=... you can see when you invoke it, it puts an overlay over each visible word with a 1-3char shortcut. You press the shortcut, and jump to that place. So yeah, YMMV and all that, but that is what I use for motion. Out of all of that, / and f are by far the most common things I use.