VIM substitution to prepare XML code samples for HTML blogs Link to heading
I sometimes need to include XML code samples in my blogs. When I do this I need a quick way to format it for HTML, more specifically, format it for whatever blogging software I’m using. Since it is infrequent I just use VIM substitution (I know, I could do this in SED but for now VIM is good enough)
From http://vim.wikia.com/wiki/Search_and_replace:
:%s/foo/bar/g
Find each occurrence of ‘foo’ (in all lines), and replace it with ‘bar’.
I search for <
or >
then replace them with <
or >
and done.
:%s/</\<\;/g
to replace all instances of <
with <
:%s/>/\>\;/g
to replace all instances of >
with >