Delete new lines from registry in vim?

I have a long list of different university names. I am trying to create a synonym table by matching strings with specific unique keywords; that is, in the file, I will determine that Harvard is the keyword here:

Harvard Business School|
Harvard College|
Harvard School of Divinity|

and paste them into another file as

Harvard Business School|Harvard College|Harvard School of Divinity|

I do this by looking for a word under the cursor, pulling the lines with that word into the register, inserting the register into another file, and using the join command ā€œJā€ to join the lines together:

[ clear register 'a' ]    
0"ay0
[ move cursor to 'Harvard" and yank lines with keyword into register a ]
:g/\<<CTRL-R><CTRL-W>\>/y A
[ move to other screen and paste ]
"ap
[ join lines ]
JJJJJ

, , . , , , JJJJ . , , "a", "a", "a".

?

EDIT: :

  • , . % S/\ //
  • "foo" , .:% S/Foo//
  • "foo" , .:% S/A//

:

  • "foo" "bar" "a" "b"
  • "foo" "bar" 'a' 'a'
+3
4

a, :

:let @a=substitute(strtrans(@a),'\^@',' ','g')

, , a .

+4

J: "apgVJ:

nnoremap <expr> gV    "`[".getregtype(v:register)[0]."`]"

. J ( : J J , ). gV : "apgV:s/{pattern}/{replacement}<CR> , "ap:let @a=substitute(@a, '{pattern}', '{replacement}', '{flags}'), - .

: a qaq : qa , q , a, .

+2

, , , Google , , .

"a

    :g/pattern/ norm "apkJ"addu

    :g/pattern/ norm pkJddu

, .

u , , , , , .

Cite:

   [ join lines ]
   JJJJJ

: 5J :%j ( )?

:

    "How do you mark text between "" in code blocks,
    not to be colour coded?"
+1

, :

|
|
|

:%s/\n//g

\n . ^ M ( + v ENTER) \n.

I'm afraid your list might be more complicated, but in this case my decision will be too "simple"

0
source

All Articles