I would particularly want to use it with the 'c' command.
[cut]
I'm using c quite often. I wouldn't remap it ;)

I think the OP wants an (in vim nomenclature) "operator pending mode mapping", so that it can be used *with* the "c" command, rather than *instead* of the "c" command.

        :onoremap > /\u<cr>
        :onoremap <lt> ?\u<cr>

This pair of mappings will allow one to do

        c>

or

        c<

to change to the next/previous start of a "camel-case word"

The 2nd mapping has problems if you're in the first "word" or on the 1st character of the 2nd word (e.g. "abcdEfgHiJklmno" and your cursor is on the "E"), so you can change the mapping to

        :onoremap <lt> ?\u<bslash><bar><bslash><lt><cr>

which will handle both cases.

There's a good bit of help on the matter scattered throughout the docs. Some suggested places to start reading:

        :help omap
        :help operator-pending
        :help map_backslash
        :help <bar>
(reading the surrounding section on bslash, lt, cr and when to use them too is helpful)

These mappings do happen to break the convenience of the ">>" and "<<" commands, as after the first "<" or ">", vim is now in operator-pending mode, so unless there is another uppercase letter on the line (before or after the cursor respectively), this will give you grief. However, you can map them to other keys if you prefer (plus/minus are rarely used, given their synonymity with j/k), or you might be able to create additional mappings for ">>" and "<<" to explicitly perform their original actions:

        :nnoremap <lt><lt> <lt><lt>
        :nnoremap >> >>

might do the trick (untested).

HTH,

-tim



Reply via email to