1

Title says it all. I could of course look at what the next capital letter in the word is and e.g. gtE but I'd like something that's:

  1. fewer keystrokes and more importantly
  2. easier to commit to muscle memory.

Is this built in or available from an existing plugin, and if not, could I make it out of Vimscript or (preferably) Lua?

1 Answer 1

4

There's no built-in motion for it but you can create your own with ease.

Let's see what we have:

  • create a mapping for normal, visual and operator-pending mode → the :noremap command does that (see :help map and :help mapmode-nvo)
  • search for a pattern → the / command does that (:help /)
  • pattern for upper case character → the \u atom does that (:help /\u)

Putting it all together we get the following Vimscript

noremap gc /\u<CR>

the corresponding (and untested) Lua code should be

vim.keymap.set('', 'gc', '/\u<CR>')

I picked gc because it's not a default command and can easily be remembered as goto capital. I'm not entirely happy with it. Feel free to pick another letter or combination thereof. Choose something you find easy to remember, easy to use and easy to commit to your muscle memory.

A notable difference to t/f is that this will match across lines.

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.