I'd like do use vim search-and-replace to replace all " with ' and vice-versa. Is there a way to achieve this in one step? I'm thinking of something like this:
:s/\("\|'\)/\1=="?':"/
Where of course the \1=="?':"
-part is something that works in vim.
Thanks in advance!
Another approach (that's more suited to scripting) is to use the built-in tr()
function. To apply it on the buffer, getline()
/ setline()
is used:
:call setline('.', tr(getline('.'), "'\"", "\"'"))
power of unix tools ;)
:%!tr "'\"" "\"'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With