title: remove newlines from a register in vim?
body: <p>I have a long list of different names of universities. I'm trying to build a synonym table by collating lines with certain unique keywords; that is, in the file, I'll identify that Harvard is the keyword here:</p>
  
  <pre><code>Harvard Business School|
  Harvard College|
  Harvard School of Divinity|
  </code></pre>
  
  <p>and paste them into another file as</p>
  
  <pre><code>Harvard Business School|Harvard College|Harvard School of Divinity|
  </code></pre>
  
  <p>I have been doing this by searching for the word under the cursor, yanking lines with that word into register, pasting the register into the other file, and using the join command "J" to join the lines together:</p>
  
  <pre><code>[ clear register 'a' ]    
  0"ay0
  [ move cursor to 'Harvard" and yank lines with keyword into register a ]
  :g/\&lt;&lt;CTRL-R&gt;&lt;CTRL-W&gt;\&gt;/y A
  [ move to other screen and paste ]
  "ap
  [ join lines ]
  JJJJJ
  </code></pre>
  
  <p>This works just fine, but I'd like it to be streamlined. Specifically, I would like to know how to remove newlines from a register so that I don't have to use JJJJ to manually join the lines in the last step. I'd like to search for all lines containing the word under the cursor, copy them into the 'a' register, remove newlines from the 'a' register, then paste the contents of the 'a' register.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT: 
  I know: </p>
  
  <ul>
  <li>how to search and replace globally, e.g. %s/\n//g</li>
  <li>how to search and replace 'foo' in a buffer from a word to the contents of a register, e.g. :%s/foo/a/g</li>
  <li>how to search for the contents of a register and replace with 'foo' in a buffer, e.g. :%s/a/bar/g</li>
  </ul>
  
  <p>What I need to know: </p>
  
  <ul>
  <li>how to search and replace 'foo' with 'bar' from register 'a' to register 'b'</li>
  <li>how to search and replace 'foo' with 'bar' from register 'a' to register 'a'</li>
  </ul>