Show HN: A New Basic Vim Motion
github.com
github.com
EasyMotion allows make any movement, say "w" for forward by word, and will then highlight the beginning of every word on the screen with a "target key". Pressing that target key will take you to that word. Similarly, doing "<EasyMotion Key>j" will do the same, but with every line down from your line (j=down), making jumping to any line, anywhere, as easy as "<EM>j{letter}".
I have EasyMotion bound to the "space" key, and I use a fork of EasyMotion that automatically highlight with 2 letters instead of one (the default is to higlight with one, and if anything is ambiguous, after pressing the first key you'll get another key to press. With this fork, you never have to "press a key then wait", you always press the two keys that appear).
I also have the letters to use mapped to something like: "asdfghjkl", e.g. the homerow keys in order, because if I mistype one of the keys, EasyMotion will take me pretty near.
So I find EasyMotion great for getting across lines and around the screen, but within the line I think seek is a more fundamental solution.
And I think you should mention EasyMotion in the Readme, I'm probably not the only one around who uses that plugin and many people probably have the same question/
(And I also had to remap the default keys away from the number row ...)
There's a nice intro video by EmacsRocks at [2].
You must be able to type any letter/number on your keyboard without looking at your keyboard that said because the way to use it efficiently consist in first looking where you want move your cursor, then invoking the shortcut while keeping your eyes on your target. That's how you can be really very efficient.
Note that the latest version can also "ace jump" across various Emacs frames (previously it was limited to buffer(s) inside the current frame).
But to be honest the thing posted here for vim is different: Emacs' ace-jump-mode is vim's easymotion and the author of this new vim navigation feature suggest also using easymotion.
But, yeah... Anyone using Emacs or vim and not using ace-jump-mode / easymotion is totally unaware of what he is losing.
Every single time I demonstrate that to coworkers I see a jaw dropping ; )
Semicolon will repeat the last jump command, and comma will repeat it in the opposite direction.
I find this very useful not only for mismatches that I didn't see, but also for help with quickly formatting text. Along side . to repeat an action, it's incredibly fast to use ; to repeat your last jump (like to < for an html tag) and then use . to repeat the last command (like dst, to delete the surrounding html tag). This is a just one example, but it's a quick and easy pattern I use to do things like selectively stripping html tags within a string that has some inline html, or moving around quickly within arrays.
It's now some years since I used vim regularly but I recall this regularly annoying me when trying to create visual selections. For example, I'd do "vt," (or whatever) expecting the selection to extend to a given point, and then find myself stuck at a , that I hadn't noticed. And then I'd have to move the cursor by hand to fix things, just like you would in some ordinary text editor.
:help cpo-;So many times I'd do an `f` search like `fs` only to realize the variable `she_sells_sea_shells_by_the_sea_shore` appears between me and my destination. Ugh!
I prefer to map the space bar to : instead. The space bar is not usually mapped to anything, so you wouldn't be masking any other function by mapping it.
Also, for jumping long distances, you should really try PreciseJump or EasyMotion. (mentioned elsewhere in this thread)
"space" to ":"
":" to ","
That makes sense. Now ; and shift-: works in pair how n and shift-N works in pair.
Regarding the motions with d, c and y, just to clarify the seek motion is available anytime. As for the others, they work similarly to iw, i" &c, and I think these operator pending motions add a great layer of flexibility to vim without needing extra base keys.
You should lower your ambitions and just make this a function one can key bind to a char of their choice.
Have you tried submitting this to vim as a patch instead? I doubt it would be approved, for a good reason. Nice work though.
1s
cl
c<space>
vc
xi
There's obviously more if you want to add '1' to a couple of these, and more still if you want to go to 3 characters.
Try this combination of options to get functionality similar to emacs's C-s:
:set ignorecase :set smartcase :set incsearch
c/<pattern><enter>
etc.Why can you not rework the "f" key itself to take 2 keys if pressed in quick succession? "f" waits a millisecond to see if another key is pressed, if not it behaves identically to the default "f", else it uses 2 or even 3.
anyhow, i don't use vim anymore but when i do, i'll give it a shot. i know i can't live without seeking, it's such an important part of your arsenal.
In combination with this it's almost as effective. Personally I'd use ctags and the http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tag-comma... search functionality of the tags. But I'll give you that normal text searching in emacs is a tiny bit more efficient :)
ie, fy;; will find the third 'y' in the line.