0

I often navigate to the next occurrence of the current non-paren character. For example,

`HTTP GET www.example.com/example/com` is an example URL.

When the cursor is at the beginning of the line at the ` character, it is useful to jump the the next occurrence of the `.

This can be achieved by f` (How to jump to a specific character in vim?), but I winder if I'm missing any single-character shortcut. If not, I'd be happy to know what's the right way to map such a key binding please.

How do I navigate to the next occurrence of the current character with s single keystroke?

1

1 Answer 1

1

It's tricky and working only for predefined pair of characters, but you can leverage matchit plugin, found on SO:

:let b:match_words='`\<:\>`'

Then you can alternate with %, though it may have caveats (see :help b:match_words).

4
  • Thanks, but I'm looking for a more general solution. I assume we can keybind it somewhow.
    – Adam Matan
    Aug 20, 2017 at 13:22
  • I guess you will need at least 2 key strokes to trigger the mapping and specify a character. There is probably a plugin for your use case, (not) like those which jump to a location specified by 2 characters: vim-seek and vim-sneak.
    – LEI
    Aug 20, 2017 at 22:23
  • It could easily be mapped to a single keystroke. See the two similar questions I linked to in the comment to the question.
    – Herb
    Aug 21, 2017 at 0:52
  • Nice catch, I didn't think of yl:normal f<C-R>"<CR> which effectively copies the character under the cursor and pastes it after f.
    – LEI
    Aug 21, 2017 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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