Vim: change formatting of variables in a script
Posted
by sixtyfootersdude
on Stack Overflow
See other posts from Stack Overflow
or by sixtyfootersdude
Published on 2010-04-22T18:40:14Z
Indexed on
2010/04/22
18:43 UTC
Read the original article
Hit count: 220
I am using vim to edit a shell script (did not use the right coding standard). I need to change all of my variables from camel-hum-notation startTime
to caps-and-underscore-notation START_TIME
.
I do not want to change the way method names are represented.
I was thinking one way to do this would be to write a function and map it to a key. The function could do something like generating this on the command line:
s/<word under cursor>/<leave cursor here to type what to replace with>
I think that this function could be applyable to other situations which would be handy. Two questions:
Question 1: How would I go about creating that function.
- I have created functions in vim before the biggest thing I am clueless about is how to capture movement. Ie if you press
dw
in vim it will delete the rest of a word. How do you capture that? - Also can you leave an uncompleted command on the vim command line?
Question 2: Got a better solution for me? How would you approach this task?
© Stack Overflow or respective owner