Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sneaky pattern searches #172

Closed
cuviper opened this issue May 16, 2016 · 5 comments
Closed

Sneaky pattern searches #172

cuviper opened this issue May 16, 2016 · 5 comments

Comments

@cuviper
Copy link
Contributor

cuviper commented May 16, 2016

Would it be possible to add a sneak mode for regular /{pattern} searches?

I just started using vim-sneak, and I'm already very happy to have this replacing the normal f and t movements for single-char searches. But now I feel there is a gap when I need to use a pattern search, and hlsearch and the jump list don't work the same way. If I could sneak through those search results too, I think that consistency would be very nice.

I'm not sure if I would commit fully to remapping this. Sometimes it is nice to have hlsearch shown, which is why I enable it at all, but often I only want to get to the right location and clear the highlight. So I think at first what I would want is to map something like g/ to a sneaky search, leaving regular / alone. This would use its own highlight instead of hlsearch, and jump with SneakNext and SneakPrevious. Bonus if it can still use incsearch as the pattern is being typed.

Thoughts?

@justinmk
Copy link
Owner

justinmk commented May 16, 2016

The intended theme of sneak.vim (and any of my plugins in general) is not to replace any part of Vim but to complement it or fill a real gap.

/ with incsearch serves its purpose very well, and wrapping it with sneak's behavior IMO is a mistake. In particular, label-mode ("streak" mode) don't make sense with incsearch: if you're entering a pattern, the keystrokes saved by on-screen matches are negligible at that point.

https://github.com/easymotion/vim-easymotion makes all these mistakes anyway, so it's available for people who want that.

Note that a related discussion is at #104 and I plan to enable the functionality discussed there, though it's stalled at the moment.

@cuviper
Copy link
Contributor Author

cuviper commented May 16, 2016

OK, thanks for considering it. I'll keep an eye on that other discussion.

@justinmk
Copy link
Owner

Sometimes it is nice to have hlsearch shown, which is why I enable it at all, but often I only want to get to the right location and clear the highlight.

I strongly recommend this sensible.vim mapping if you aren't already using it:

nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>

Just mash <C-L> whenever you want to clear incsearch.

@cuviper
Copy link
Contributor Author

cuviper commented May 16, 2016

Yep, I do use <C-L>! Actually, it might be a nice way to clear sneak highlights too, without waiting for movement. I suppose I can just add call sneak#hl#removehl()?
(edit: call sneak#cancel() looks more appropriate)

@justinmk
Copy link
Owner

Actually, it might be a nice way to clear sneak highlights too, without waiting for movement.

Sure, or <Esc> works by default if you are running GUI Vim or Neovim (terminal and GUI), and don't already have it mapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants