Search code examples
vimneovimcode-editor

How to change part of a variable/function name in Vim


I usually have variables/function names like:

loginUser()
registerUser()
saveUserData()
checkBaggageTag()

So, as you see, some of them repeat the User word, and so when I copy paste and need to rename one of them, I do it this way: loginUser() I'll do cw and write registerUser.

Here is the question, is there a way to do cw but only change the word up to the first Uppercase letter? (U in User for example) so I can avoid retyping the word User? Of course, I can always do vtUc and then type register but you know, that's 4 keys...is there a way to it in fewer?

Thanks for your help ^_^


Solution

  • Using command t: ctU (change till the next U).

    Using search: c/UEnter

    Searching to the next upper-case latin letter (not only U): c/\uEnter