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

reset , ; when f remapped #114

Closed
msprev opened this issue Jun 9, 2014 · 5 comments
Closed

reset , ; when f remapped #114

msprev opened this issue Jun 9, 2014 · 5 comments

Comments

@msprev
Copy link

msprev commented Jun 9, 2014

vim-sneak is brilliant! Thank you for all your great work on it!

I use a Dvorak layout and I have s and f swapped (f is a pain to press in Dvorak). sneak is mapped to another key.

noremap s f
noremap S F

My problem is that sneak does not reset the binding of ; and , when I invoke an f-search by pressing the s key; ; and , remain bound to sneak. I can manually reset these bindings by calling sneak#reset('f'), but this is clunky to do after every f-search.

I realise that sneak is not designed to work with f-enhancements, but is there any workaround for getting sneak to work with simple remapping of f?

@justinmk
Copy link
Owner

justinmk commented Jun 9, 2014

Supporting alternate keyboard layouts is definitely a goal, although until now I hadn't heard any interest in it (even from non-US users).

I realise that sneak is not designed to work with f-enhancements,

Not out-of-the-box, at least :) But I always assumed it could be done with a creative mapping, but actually I think that was a bad assumption. The easiest way to achieve this right now is to let sneak take over your f and t (or s in your case). But it's understandable if you don't want that. Let me think about it.

@msprev
Copy link
Author

msprev commented Jun 9, 2014

Thank you! It's not a specific issue for Dvorak, only for those who have remapped the keys for whatever reason...

I'd like to keep the default f and t behaviour if possible. I find it useful with short-range movements to be restricted to moving inside a single line (when mashing ; or , for example)

I couldn't think of a mapping solution to do what I wanted. Ideally, I'd like my remapping of f and s to call sneak#reset('f') so that ; and , are freed from sneak. But I couldn't figure out how to do it.

Thanks again for your great work on sneak and neovim.

@justinmk
Copy link
Owner

justinmk commented Jun 9, 2014

It turns out my assumption was correct. Here's the "creative mapping" that should satisfy your request:

noremap <expr> s sneak#reset('f')
noremap <expr> S sneak#reset('F')

<expr> is important. Also, if you use a snippets plugin, you probably shouldn't use noremap, but instead should explicitly list nnoremap, xnoremap, and onoremap, like this:

nnoremap <expr> s sneak#reset('f')
nnoremap <expr> S sneak#reset('F')
xnoremap <expr> s sneak#reset('f')
xnoremap <expr> S sneak#reset('F')
onoremap <expr> s sneak#reset('f')
onoremap <expr> S sneak#reset('F')

Thanks again for your great work on sneak and neovim

You're welcome!

@justinmk
Copy link
Owner

Feel free to re-open if there's still a problem.

@msprev
Copy link
Author

msprev commented Jun 10, 2014

Brilliant! Thank you very much. I've learnt a new trick from this.

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

No branches or pull requests

2 participants