Skip to content

Instantly share code, notes, and snippets.

@keeganstreet
Created June 9, 2011 08:33
Show Gist options
  • Save keeganstreet/1016331 to your computer and use it in GitHub Desktop.
Save keeganstreet/1016331 to your computer and use it in GitHub Desktop.
Vim command for converting multiline HTML into concatenated strings

For converting this:

<ul>
	<li><a href="#" id="btnLogin">Login with Facebook</a></li>
	<li><a href="#" id="btnLogout">Log out</a></li>
	<li><a href="#" id="btnSelect1">Select friends</a></li>
	<li><a href="#" id="btnSelect2">Select friends in a seperate instance with different options</a></li>
</ul>

Into this:

'<ul>'.
	'<li><a href="#" id="btnLogin">Login with Facebook</a></li>'.
	'<li><a href="#" id="btnLogout">Log out</a></li>'.
	'<li><a href="#" id="btnSelect1">Select friends</a></li>'.
	'<li><a href="#" id="btnSelect2">Select friends in a seperate instance with different options</a></li>'.
'</ul>'.

Just because I like to export my HTML as one long line. E.g: View source at http://design.radissonblu.com

:22,49s/^\(\s\+\)\(.\+\)$/\1'\2'./
# To convert back to normal:
:22,49s/^\(\s*\)'\(.\+\)'\.$/\1\2/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment