A common process for me is to have a camelCased word that I wish to prepend to. I find the vanilla method a little too cumbersome as I will describe below. What I'm wondering is if there is a better method.


function foo() {

In this the doSomething is in camel case and I want to turn it into shouldDoSomething.

Things I've tried

Usually I will place the cursor at the beginning of the word and press ~hishouldEsc. However, this requires positioning the cursor correctly and performing a few operations one of which needs to be undone (~ move cursor to the right requiring an extra h).

I have also used tpope's vim-abolish Coercion by placing the cursor on the correct line and then Isomething_Esccrc. Unfortunatly the result of which is shouldDosomething not shouldDoSomething.

2 Answers 2


You can use s to delete the current letter and put you in insert mode.


This will let you delete the s insert shouldD yielding shouldDoSomething

Note: assuming you are on the d.


how about b g g U l i should Esc?

You can save that into a macro and re-use it if you need to do it a lot. Otherwise don't bother optimizing a task you only do once anyway.


If you want to make this a macro you can do qqbgUli<C-o>q to save it into the q register. Note that the macro would only be recorded as qqbgUli, since <C-o>q is what stops the recording without leaving insert mode.

You can also just map it to something like <C-i> or <leader>i if you use it often. map <leader>ic bgUli (ic as in Insert preserving Camel-case)

  • Isn’t that the same thing as ~? Haven’t really gained much. Though the macro idea is nice.
    – Sukima
    Nov 7, 2017 at 23:44
  • Would the <Ctrl-o>q cause the second run of the macro to start recording again? Seems like :let @q = “bgUi” work better?
    – Sukima
    Nov 7, 2017 at 23:50
  • ~ toggles case, which is faster, but gU sets uppercase, which is more accurately what you want. Using let should also work, but the <Ctrl-o>q is what stops recording the macro i the first place without leaving insert mode so you can then type the word (assuming it's not always the same, "should") Nov 8, 2017 at 7:07

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.