title: What is the best way of converting this error message into an SQL statement using vim?
body: <p>When working on a developer database, I frequently get an error message which implies that I need to run a simple SQL statement to clean up the database, based on the contents of the error message. However it is a pain to cut and paste from the error message to create the appropriate SQL statement, so what I would like to do is run a few commands from Vim to construct the SQL statement, and I'm trying to figure out the most efficient way to do it. The format of the error message is:</p>
  
  <pre><code>com/changelogs/1-changelog1.xml::changelog1name::dev1 is now: 30e70b7
  com/changelogs/2-changelog2.xml::changelog2name::dev5 is now: 4jkerui
  com/changelogs/7-changelog1.xml::changelog7name::dev4 is now: 43jer7r
  </code></pre>
  
  <p>I need to null out the md5sum column for each of the offending changelogs, so I need to convert the above error message to an SQL statement in the format:</p>
  
  <pre><code>update databasechangelog set md5sum=null where id in
  ('changelog1name','changelog2name','changelog3name')
  </code></pre>
  
  <p>So, for example, in Vim, I could do something like:</p>
  
  <p>Extract the changelog names:</p>
  
  <pre><code>:%s/^.*::\(.*\)::.*$/\1/g
  </code></pre>
  
  <p>Add a single quote to the start of each line:</p>
  
  <pre><code>:%s/^/'/g
  </code></pre>
  
  <p>Add a closing quote and comma to the end of each line:</p>
  
  <pre><code>:%s/$/',/g
  </code></pre>
  
  <p>After this I can type in the leading part of the SQL statement and the conversion is complete. However, typing in these commands is a pain, and what I would like to do is have the sequence of commands aliased to a keypress or user defined command in Vim. I've tried the following in my .vimrc but it only runs the first command:</p>
  
  <pre><code>noremap &lt;F2&gt; :%s/^.*::\(.*\)::.*$/\1/g | :%s/^/'/g
  </code></pre>
  
  <p>Hence my questions are:</p>
  
  <ol>
  <li>What is the best way to achieve the conversion? Are the above commands sensible, or is there a more efficient way? e.g. a command that will extract all of the names and construct the correctly formatted list in a single command, rather than three commands</li>
  <li>What is the best way to configure Vim to run all of the commands in a sequence, based on a keypress or user-defined command?</li>
  </ol>