Here's a snippet that I'm working with (* denotes cursor location)
*"First random string" ,"Random string I want to remove" }
"Random string number 2" , "Another random string I want to keep" }
To:
*"First random string" , }
"Random string number 2" , "Another random string I want to keep" }
The brackets are aligned neatly with each other with spaces, and I want to remove the last argument from the first array (while maintaining the easy readability of the current bracket, and comma placement.
The easy answer (the one I'm forced to do for now) would be to count the number of characters in the string and do
<count>r<space>
but that easily gets tedious with strings of the length I'm working with.
I'm sure there's a better way to directly replace the text. I'm sure that vim has a visual replace feature but <select text>r<space>
doesn't work.
fRva"R<space>
not work?R
is not allowed from visual mode, but that may have changed. But3f"va"
seems to be easier, so you don't have to find a char in second string that's missing in the first one.r
instead ofR
. I have tested this on Vim 7.2qqf,lvt}r<space>
should do the recording and then you can go to another line and apply the macro with@q
. You can find the lines with/\v.+\}
. Then you can move to lines you want to replace withn
and then apply the macro (with@q
, as I wrote)r<space>
over a visual selection works as expected