Skip to content

Instantly share code, notes, and snippets.

@mattboehm
Created December 12, 2012 21:19
Show Gist options
  • Save mattboehm/4271741 to your computer and use it in GitHub Desktop.
Save mattboehm/4271741 to your computer and use it in GitHub Desktop.
Crappy Vim "mail merge"
"I recorded a macro of the command. These are the keystrokes I hit to do one line
"To do all lines, I recorded the macro in register q (starting on the first line of names.csv)
"then did 2@q to repeat macro twice more.
"This assumes the template is in the same dir and is very brittle
"You should use a templating engine like genshi for non-trivial templating, but just wanted to show that this is possible
"Creates $email.html file for each email address.
0"ayt,f,l"by$:new^M;read template.html^M:%s;\$EMAIL;^Ra;g^M:s;$NAME;^Rb;g^M:w! ^Ra.html^M:bd^Mj
<html>
<body>
Hello, <a href="mailto:$EMAIL">$NAME</a>!
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment