hlissner / evil-snipe

2-char searching ala vim-sneak & vim-seek, for evil-mode
MIT License
340 stars 25 forks source link

[feature] Operating on incrementally extended regions #22

Closed PythonNut closed 8 years ago

PythonNut commented 9 years ago

Okay, evil-snipe is super cool because it lets you think: okay, I want to jump to that z over there, so fz. Oh, I'm not there yet? I'll just mash f until I am. This is great because I have to worry less about those pesky letters that always seem to creep up between my point and target.

At the moment this doesn't extend to using motions as the ranges for an operator. dfz does work, of course, but if you missed that other z (the one sneaking between your point and your goal) then you're left having deleted less than you intended. This time, though, f won't save you. It'll search, but it won't extend the deletion.

I'm not entirely sure how to go around this.

One simple way to solve this would be to simply undo the last operation and redo a new operation on the extended region, potentially in an invisible buffer so it doesn't jar the UI. The only caveat is that not all operations can be undone.

Another way would be to delay the operation until after the transient map terminates: df f f f Up now the deletion is done. Of course, this sort of violates the vim timing paradigm, so that's not a perfect solution either.

You could just repeat the whole operation. That's pretty clean and side effect free, so long as you don't mind ("the cz" "the czechoslovakian food is amaz" "the czechoslovakian food is amazing z" ...) in your kill-ring. (I wouldn't mind too much, but maybe other people would)

A (hardly comprehensive) list of solutions to a problem that maybe doesn't even deserve solving

What do you think?

hlissner commented 9 years ago

This would be nice for snipe's fluidity. Manipulating the kill-ring after the fact and repeating the whole operation should be doable, but I'll have to look into it. It'll involve capturing the operator and mimicking it. evil-surround does this, so I'll check out its implementation.

Note that you can currently do what you are asking with evil-repeat (.), but only in one direction. E.g. dzcz . .. I could simply remap transient map keys to evil-repeat for delete/change operations, but again, only in one direction. Unless I map the reverse key to an evil-snipe-undo-maybe type of function that undos only up to the first operation.

Anyhow, I'm on the case!

PythonNut commented 9 years ago

Note that you can currently do what you are asking with evil-repeat (.), but only in one direction. E.g. dzcz . ..

Not quite, because you can't then go and p the entire string... it's recorded in the kill-ring as separate pieces. You'd have to pPPpPPpPP to get the whole thing out in the right order again.

Manipulating the kill-ring after the fact and repeating the whole operation should be doable, but I'll have to look into it.

I'm not sure how specific vs. general we need to be. If we focus on the kill-ring, we'll have an inconsistency because, d and, say, = don't behave the same (to say nothing of homegrown operators!).

Anyhow, I'm on the case!

Thanks!

ghost commented 9 years ago

I have been meaning to post the same thing.

When you are doing this, you should look into repeat operations "leaking through" into insert mode (a teensy bug).

Pressing c t r and then t (to type the letter t in insert mode) makes evil-snipe jumps to the next instance of r instead.

Note that something similar to this might be a feature, not a bug. If you meant to clear to amaz, but only got to czechoslovakian being able to press t again is a good thing.

(But this leads to inconsistent behavior if you meant to type the letter t. You could add a timeout so that t means repeat clear until 0.2 seconds for example, but this is a tiny thing not worth bothering with unless you want to. I think syl20bnr implemented a timeout in avy which might be worth looking at.)

ghost commented 9 years ago

This reminded me of another teensy annoyance; in visual-mode pressing f/F to repeat searches does not work.

hlissner commented 9 years ago

@endrebak I should have an immediate solution for the repeat operations leaking through from operator into insert mode. As for repeating searches with f/F in visual mode, this is something I already plan to address in evil-snipe 2.0.

Thanks for reporting! Though for future reference, please put these in separate issues. It helps me keep track of my TODO's.

ghost commented 9 years ago

Understood and thanks.

hlissner commented 8 years ago

I think evil-easymotion fills this gap perfectly, so I'll consider this resolved.

PythonNut commented 8 years ago

@hlissner sure. Just wanted to throw this out there, in case we could come up with something. :)