justinmk / vim-sneak

The missing motion for Vim :athletic_shoe:
http://www.vim.org/scripts/script.php?script_id=4809
MIT License
3.26k stars 88 forks source link

mimic the behavior of easy-motion j and k #270

Closed NikoKS closed 3 years ago

NikoKS commented 3 years ago

I love vim-sneak label mode much more than easy-motion because it's lightweight, doesn't mess with syntax, and compatible with LSP like coc.nvim.

I was able to implement my most needed sneak-motion: labeled 1-character f sneak by following the example on vim-sneak help page

But I'm still missing my second most needed sneak motion, that is go to start of line (similar to easy-motion j and k). I know I can just type the character at the start of the line and sneak there, but It proves to be not too effective as sometimes it ran out of sneak label to use.

I was wondering If this behavior can be implemented using vim-sneak function? Or if this feature can be implemented? I'm thinking that if I can sneak to right after a newline character '\n' this might be possible?

Thank you for the time. Any help or insights would be most welcome.

justinmk commented 3 years ago

go to start of line (similar to easy-motion j and k). I know I can just type the character at the start of the line and sneak there

For reference: https://github.com/easymotion/vim-easymotion/blob/d75d9591e415652b25d9e0a3669355550325263d/doc/easymotion.txt#L422-L449

You can do it using the SneakEnter event:

autocmd User SneakLeave norm! ^

That changes the behavior for s. Doesn't apply to motion repeat (;).

In order to change the behavior only for certain mappings, you would need to map to a function that sets a ++once handler:

autocmd User SneakLeave ++once norm! ^