1

To advance to the next/previous character match on a line I can do:

  • f <char>

However, I find myself wanting to match against two characters on that line, for example, something like:

  • f ='

Is this possible to do? Or do I need to do a full search at the bottom (starting with /). I find the search to be a bit 'out of the way' and prefer using f/F when I can!

  • 1
    There is a plugin which does this: vim-seek; I think there was also another one, but can't recall the name. – Martin Tournoij Apr 12 at 9:16
2

Vim provides the f, t or F, T command to jump forward or backward to a character in current line, and you can repeat the action by pressing , or ;. While these commands are useful, they are not powerful enough to be of real value:

  • The movement is restricted to current line.
  • There are possibly many repetitions since you can only provide one character.

vim-sneak solves these two issues neatly. With vim-sneak, you can go anywhere your eyes can see in just four key strokes in most cases, which is one of the most amazing plugins I have ever seen.

After installing this plugin, add the following minimal settings to your configuration:

let g:sneak#label = 1
nmap f <Plug>Sneak_s
nmap F <Plug>Sneak_S

The above settings will map f and F to search forward and backward respectively and use the sneak label mode.

For example, if you want to go to the character i which is followed by m, first press f, then press im, all occurrences of im will be highlighted and given a label.

Press the character in a label, the cursor will jump to that location, which is really amazing.

Another similar vim plugin is vim-easymotion.

Ref: precise cursor movement in vim.

| improve this answer | |
1

Some plugins make it possible. The one I tried out is called sneak and is quite good. Its readme list other similar plugins that you can try

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.