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

Sneak_f + s_next ("clever s") breaks :normal #264

Open
mattboehm opened this issue Sep 8, 2020 · 4 comments
Open

Sneak_f + s_next ("clever s") breaks :normal #264

mattboehm opened this issue Sep 8, 2020 · 4 comments

Comments

@mattboehm
Copy link

mattboehm commented Sep 8, 2020

I recently updated my vimrc to use sneak's versions of f/t:

let g:sneak#s_next = 1
map f <Plug>Sneak_f
map F <Plug>Sneak_F
map t <Plug>Sneak_t
map T <Plug>Sneak_T

However, if I try to run a command like :%normal f(D, I often get unexpected results. For instance on this file:

a(b)
c(d)

I end up with:

<blank line>
c(d)

(<blank line> is a literal blank line)

If I unmap f, I get the expected result:

a
c

Do you know if there's a fix/workaround for this? Thanks!

@mattboehm
Copy link
Author

I think I'm going to have to make a custom :Normal command that disables sneak first and re-enables it afterwards. I've used :normal! to get around this, but this disables other custom mappings that I'd like to still be able to use.

@justinmk justinmk changed the title <Plug>Sneak_f does not always work as expected with :normal <Plug>Sneak_f with "s_next" option does not always work as expected with :normal Jul 3, 2021
@justinmk
Copy link
Owner

justinmk commented Jul 3, 2021

With s_next disabled it works fine. The problem seems to be g:sneak#s_next=1 ("clever s"). Not sure anything can be done here, because "clever s" works by setting up temporary mappings.

@justinmk justinmk changed the title <Plug>Sneak_f with "s_next" option does not always work as expected with :normal Sneak_f + s_next ("clever s") does not always work as expected with :normal Jul 3, 2021
@justinmk justinmk changed the title Sneak_f + s_next ("clever s") does not always work as expected with :normal Sneak_f + s_next ("clever s") breaks :normal Jul 3, 2021
@mattboehm
Copy link
Author

@justinmk hmm I was thinking I could fix my specific problem by toggling this setting off/on on CmdLineEnter/CmdLineLeave events, but I believe these settings are just read once on init(). The best hack I can think of for now is to unmap/remap f/t on these events.

Actually, CmdLineLeave probably triggers before the normal mode changes are executed, so I'd probably actually need to wrap :normal in a custom command that does this.

@ggandor
Copy link
Contributor

ggandor commented Jul 9, 2021

@mattboehm Awesome, you might just have solved a problem regarding our somewhat related issue (which in fact could apply to Sneak too). CmdlineEnter seems a fine way to detect :normal execution, I haven't thought about that. Many thanks :) CmdlineLeave triggering before the actual execution of the changes seems a problem though.

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

3 participants