VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.81k stars 1.31k forks source link

Add "clever-f.vim" functionality to VSCodeVim #5272

Open macintacos opened 4 years ago

macintacos commented 4 years ago

I like f/F/t/T for quickly navigating to the next occurrence of a letter, and think that easymotion is a bit too heavy-handed in accomplishing this. clever-f.vim is a plugin that makes "go to next occurrence of character you just searched with f/F/t/T" the same character you started the motion with instead of using ;/,, allowing you to free those up for other things (like remapping for <leader> or whatever). The addition of visual queues (similar to easymotion) that help you quickly navigate to the appropriate match that you intended makes this plugin really nice in practice when in Vim, and I wish I had it in VSCode.

Describe the solution you'd like I'd like clever-f.vim, but in this extension.

Describe alternatives you've considered Tried figuring out how to implement it, but I'm pretty new to extension authoring. Don't know how to accomplish this.

Additional context Full details of how the plugin works is in their README.

macintacos commented 4 years ago

Just realized that they have a handy little demo here to see what it's like: http://rhysd.github.io/clever-f.vim/

JW9506 commented 4 years ago

doesn't / + [stuff you want to search] + n / N do exactly what it does?

macintacos commented 4 years ago

Sure, but you could say the same thing about easymotion, which is far more involved, but is implemented in this extension anyway.

JW9506 commented 4 years ago

Sure, but you could say the same thing about easymotion, which is far more involved, but is implemented in this extension anyway.

To me, easymotion helps me go straight to the target without having to cycle through the list, which is inherently different. This clever-f.vim is just another version of / search but disguise itself using t/f prefix. t/f is great in itself because it locks the scope in just the line you are in.

macintacos commented 4 years ago

It has inherent additional utility like freeing up ; and , for other mappings, as well as just being a more intuitive (IMO) implementation of those motions overall (with the addition of visual cues to help navigate). I find that plugin to be really helpful when navigating around in Vim, and think it'd be a useful addition.

If you just want to use / to "do the same thing", that's fine, nobody's forcing you to use something else. Just like easymotion is something you can enable/disable, I'm not suggesting that clever-f be the "default" functionality, but rather something you can enable if you'd like it. It's just something that I would like to be added.

JW9506 commented 4 years ago

You can just override the default mappings and rewire them to / to do something that is really close to your need. if you notice the pattern they do with the implemented plugins, they had to give ways to the default classic vim binding, and only bind the functionality to a long obscure string (to make sure they don't run into conflict). So they probably won't make a plugin just to upgrade the t/f that do what you need.

macintacos commented 4 years ago

With all due respect, I think I'll leave that up to the maintainers to decide whether or not this will/will not be added. I've already tried overriding the defaults, and the functionality I want is something that'd need to be added to the extension itself. This is just a feature request, not a demand.

JW9506 commented 4 years ago

@macintacos "vim.normalModeKeyBindingsNonRecursive": [ { "before": [ "f" ], "after": [ "<leader>", "<leader>", "f", ] }, { "before": [ "F" ], "after": [ "<leader>", "<leader>", "F", ] }, { "before": [ "t" ], "after": [ "<leader>", "<leader>", "t", ] }, { "before": [ "T" ], "after": [ "<leader>", "<leader>", "T", ] }, "vim.visualModeKeyBindingsNonRecursive": [ { "before": [ "f" ], "after": [ "<leader>", "<leader>", "f", ] }, { "before": [ "F" ], "after": [ "<leader>", "<leader>", "F", ] }, { "before": [ "t" ], "after": [ "<leader>", "<leader>", "t", ] }, { "before": [ "T" ], "after": [ "<leader>", "<leader>", "T", ] }, } I tested these and they work pretty good. We don't need a feature for this as this can be easily customized.

macintacos commented 4 years ago

@JW9506 I've already tried that, and that's not the same functionality as clever-f. Clever-f allows me to go back/forwards in the midst of a motion, and use the same exact key to perform each forward/backward motion, something that easymotion (what you are mapping there) does not enable.

205g0 commented 1 year ago

@jpoon, pls check this issue again; clever-f's UX is unmatched for same-line goto and all other solutions like vim's og , and ; after f is pressed are way inferior and much more mental overhead and enough to distract from coding. Thanks for looking into this again!

Edit: To those who mention easymotion or / or think of something like sneak: While they're all great, they are different tools for different use cases (hint, NOT same-line goto) and much, much slower because the need more mental energy and/or key presses.

jpoon commented 1 year ago

@205g0 hey, thanks for the pr and the ping. I'm no longer actively maintaining this project. cc @J-Fields .

205g0 commented 1 year ago

cool, thanks for the hint. @J-Fields what do you think of moving via f instead of , and ;?

darianmorat commented 7 months ago

I think that implementing Quick-scope can help a lot, instead of cycling between the words you can jump directly where you want highlighting unique characters when f & F are pressed, and sure, you are keeping the default vim behavior and not using easymotion or other search motions that search in the whole file