
Show HN: A New Basic Vim Motion - goldfeld
http://github.com/goldfeld/vim-seek
======
edanm
This sounds very similar to EasyMotion, which is an amazing plugin that I hope
everyone tries.

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.

~~~
SilasX
Interesting, that's like what Pentadactyl (a vim-based plugin everyone should
also use) does for links on websites, but for text in vim instead.

(And I also had to remap the default keys away from the number row ...)

~~~
SatvikBeri
Vimium for Chrome is yet another similar plugin (but the keys start mapped to
home row, similar to vim.)

------
zefhous
Another built-in solution to the problem of mismatches when using the jump
commands (f, t, F, T) is the use of ; and ,

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.

~~~
danneu
I remapped `;` to `:` (try it, it's fun!) and evolved my character jump usage
into just using `/` + two characters of resolution.

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!

~~~
gnosis
You're missing out on using the normal meaning of ; which is really useful.

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)

~~~
z92
Reading your comment I have just mapped

"space" to ":"

":" to ","

That makes sense. Now ; and shift-: works in pair how n and shift-N works in
pair.

~~~
goldfeld
Good idea, I have just remapped mm (mmw feels natural in Dvorak) to : and my
pinkies are gonna be thanking you two many times over.

------
tsm
I like the idea, but am more reluctant about the keybindings--I use `s` almost
every day. More importantly, I'm infatuated with the marriage Vim has between
motions and actions-over-a-range, and think it's very weird to have motion
commands that are only available after {d, c, y}.

~~~
wahnfrieden
Could you explain your use cases of `s`? I've basically never found a use for
it given `c` and `r` or `R` but maybe I'm missing something.

~~~
tsm
Maybe 3 needs to become 42. Maybe x needs to become price. Maybe miapelling
needs to become misspelling. I pretty frequently have a one-character thing
that needs to be replaced.

~~~
wahnfrieden
Thanks, makes sense. I've done that in slower ways since I've ignored s.

------
btipling
Interesting, but I am not willing to surrender a basic key binding like `s`
with what can be done with /. It is only an extra key to do the same thing.

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.

~~~
goldfeld
I actually used to use the single 's' keypress a lot. But at the same time I
wasn't happy about that habit, it was often lazy-thinking, instead of using
things like cf{char} or even cw, ce. So I committed to use '1s' when I really
needed the single substitution, and it worked really well, so I felt I had
gained on both sides. Just try and see what you think, you can always remove.
And yes I will make it customizable, but I especially wanted to release this
first opinionated version exactly to get feedback like this. Thanks.

~~~
fishtoaster
As a little thought exercise, I'm trying to see how many commands I can think
of that are equivalent to s. So far:

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.

~~~
goldfeld
Never knew about c<space> (and d and y), I think it would be the easiest.
Though I'm happy with 1s and now that I think about it, these
{operator}<space> beg to be remapped to something else entirely, maybe inner
word or the function's name? I'll play around with onoremap <Space> iw

------
ghratch
How is this better or different than incremental search? Incremental search
means it jumps to the first match as soon as you start typing after '/': you
don't need to press enter.

Try this combination of options to get functionality similar to emacs's C-s:

:set ignorecase :set smartcase :set incsearch

~~~
goldfeld
I've had exactly these three settings for a while, and I've just tested and
incsearch didn't take to the match without enter. It's a great feature though,
but I don't think I'd want it to take me, it would always fire early, say if I
would be typing 'th' it would go to 'the' when really I had wanted 'though'
some words next.

------
jayferd
Using / for a motion is way more useful imo.

    
    
        c/<pattern><enter>
    

etc.

------
crazydiamond
To the creator: What about all the other plugins and macros that already use
"s" ? I'd love to try this out, but remapping basic keys has always led to
some other function or mapping or macro suddenly failing.

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.

~~~
goldfeld
That's an interesting proposition, I'll see what I can do to offer the
alternative of making f ambiguous instead of using s. I don't think it could
be the default because most users wouldn't be as quick to type the three
letters, at least at first, and it would need to timeout really fast so as to
keep f's original responsiveness to single letters.

------
Symmetry
While I'm normally of the opinion that 's' is almost begging to be remapped, I
don't think that this is different enough from '/' to warrant a first-class
place. OTOH mapping the Easy Motion trigger from '\\\' to 's' might be worth
it.

------
jaequery
this really is a sorely needed feature. vi/vim's lack of "seeking" was really
one of the main reasons why i switched to emacs. emacs has a really nice seek,
which is just ctrl+s and type whatever you are searching for w/o you needing
to hit enter, and you are there. then ctrl+s again to the next match or ctrl+r
for reverse.

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.

~~~
ghratch
As I stated in a previous comment, it's called "incremental search" and you
can do it in vim. Look here for how:
[http://linuxcommando.blogspot.com/2008/06/smart-case-
insensi...](http://linuxcommando.blogspot.com/2008/06/smart-case-insensitive-
incremental.html)

~~~
jaequery
yea but unfortunately it's not that good ... think it's better than default
search but a still too slow as a mean for code navigation (atleast for my
taste). it's mainly due to needing to hit enter, which escapes everything,
there should be a way to hit next occurrence and prev without leaving the
/search box.

~~~
krunaldo
n for next match, N for previous match.

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...](http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tag-commands)
search functionality of the tags. But I'll give you that normal text searching
in emacs is a tiny bit more efficient :)

------
locheng
very nice plugin. I fall in love with it immediately. I am a heavy 'ft' 'yt'
'ct' 'dt' user, this plugin comes naturally to me.

------
TallboyOne
Sidenote: The ; key will repeat an f or F search, going in the appropriate
direction.

ie, fy;; will find the third 'y' in the line.

