Vim: Add "clever-f.vim" functionality to VSCodeVim

Created on 28 Sep 2020  路  9Comments  路  Source: VSCodeVim/Vim

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.

All 9 comments

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

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

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

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.

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.

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.

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.

@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.

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waltiam picture waltiam  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

elithrar picture elithrar  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

stefanoio picture stefanoio  路  3Comments