How to move through words in camel-cased identifiers in Vim?

In situations where approaches using only built-in Vim instruments are preferred, the following search commands can be used.

For jumping to the next uppercase character:

/\u

For moving the cursor one character to the right of the next uppercase character:

/\u/s+

or

/\u\zs

If one expects to use a movement like that often, one can always define a key mapping for it as a shorthand, e.g.:

:nnoremap <leader>u /\u/s+<cr>

I don't think there is anything built-in.

As @ib. indicates, you can use a regular expression motion, but it’s not particularly easy to type. However, there is camelcasemotion plugin that adds the necessary motions, for this, as well as underscore seperated identifiers.

Tags:

Vim