tags:

views:

1017

answers:

2

I have the following use case, my file contents look like this

a
b
c

I want a regular expression to do this

a|
b|
c|

Can you recommend a regex in vim?

+2  A: 

This will work for basic scripting purposes

 sed 's/$/|/' filename

for vim

:%s/$/|/g

the g is for global, but not needed

TStamper
it is not a Vim, is it?
Mykola Golubyev
just updated with vim
TStamper
+13  A: 

Type the following in VIM

:%s/$/|/

This means replace the end of line represented by $ with the string |.

Mykola Golubyev
Beat me by 17 seconds!
Paul Tomblin
Sorry man. At least once I did it ;)
Mykola Golubyev