How about cI<char><CR>
?
The LHS of a mapping is a static string. You can't have a "dynamic" mapping with, say, a placeholder character that gets replaced with whatever character the user types. I suppose you could brute-force it and enter mappings for all the relevant chars: cIw
, cIW
, cI(
, etc. I'm guessing you're hoping for something better than that.
I can think of one way to get close to what you want. Create a function and mapping like these (you can put them in your vimrc file):
function! ChangeInsideChar()
let l:char = input("Enter a character: ")
exec 'normal! f' . l:char . 'di' . l:char
startinsert
endfunction
nnoremap cI :call ChangeInsideChar()<CR>
When you hit cI
in Normal mode a prompt will appear. Enter the appropriate character then hit Enter and the magic will happen. Using your example, if at the prompt you entered ( and Enter that will delete the text inside the next set of parens and leave you in Insert mode.
You can enter these sequences pretty quickly so in effect this solution is like just adding one extra key press to your hoped for binding. Heck, I've already thought of a few ideas for using this general technique myself.
Update: Thanks to a pointer from Rich, here, we can eliminate Enter because Vim has a single char fetch function. Here's the new and improved function:
function! ChangeInsideChar()
echomsg 'Enter a character '
let l:mychar = nr2char(getchar())
exec 'normal! f' . l:mychar . 'di' . l:mychar
startinsert
endfunction