I'm doing a project-wise refactor and I want to change variable names from camelCase
to snake_case
. I have YCM and vim-abolish installed. Let's say I have the following source file:
dueDate = ...
processDueDate(dueDate);
- With
vim-abolish
I can presscrs
on every word to change them to snake case. The bad thing is this method is error prune. I can easily forget to change one of them and I will have errors. - With YCM, I can do
:YcmCompleter RefactorRename due_date
ondueDate
and it will change all of the occurrences ofdueDate
todue_date
which is good for me. The bad thing is I have to type the new variable name. This is a pain if the variable name is long.
I want to combine these two methods and map it to some key. Currently I have this:
nnoremap <leader>yr :YcmCompleter RefactorRename <C-R>=expand("<cword>")<CR>
Which is better than having nothing but I still need to delete some part of the expanded word and write it myself.
My question is how can I call vim-abolish
's function on the expanded word? Tried the following one but obviously it didn't work:
nnoremap <leader>yr :YcmCompleter RefactorRename call <Plug>(abolish-coerce)<C-R>=expand("<cword>")<CR>