Today I needed to perform multiple transforms on a chunk of text in a file and found a nice solution in Vim! Initially I was thinking about
VISUAL mode in Vim and chaining transforms the way I would do with
s/one/two/g;s/^/ /;s/$/,/). It turns out this doesn’t exactly work in Vim, but it’s not too far off the mark.
The following syntax works in Vim
:%s/^/ / | %s/string/replace/g | %s/$/,/
VISUAL mode, the sytax is slightly different. Select a bunch of lines to operate on, and then use the following:
:'<,'>s/^/ / | :'<,'>s/string/replace/g | :'<,'>s/$/,/