Vim Tips Wiki

Joining two lines of text based on pattern

Redirected from VimTip1043

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 1043 Printable Monobook Previous Next

created 2005 · complexity basic · author mej · version 5.7

Let's say you copy and pasted a bunch of output from CVS like this:

/opt/data/cvs/ofc/ofc/R1/wlthmgmt/common/feeds/state/logship.state.conf,v  <-- logship.state.conf
new revision: 1.4; previous revision: 1.3
Checking in statemch/logship.statemch.conf;
/opt/data/cvs/ofc/ofc/R1/wlthmgmt/common/feeds/statemch/logship.statemch.conf,v  <--  logship.statemch.conf
new revision: 1.4; previous revision: 1.3
Checking in swift/logship.swift.conf;
/opt/data/cvs/ofc/ofc/R1/wlthmgmt/common/feeds/swift/logship.swift.conf,v  <-- logship.swift.conf
new revision: 1.3; previous revision: 1.2
Checking in tmark/logship.tmark.conf;
/opt/data/cvs/ofc/ofc/R1/wlthmgmt/common/feeds/tmark/logship.tmark.conf,v  <-- logship.tmark.conf
new revision: 1.4; previous revision: 1.3

and you want to submit the filename and revision as a promotion request.

You can do a bunch of ":s/foo//" commands to get rid some of the junk there, and a ":g/^Check/d" and ":g/^done" to get rid of the extraneous line and you'd be left with maybe something like this:

-- 1.4 -- install
-- 1.2 -- install
-- 1.4 -- install
-- 1.5 -- install
-- 1.3 -- install

What would you do to "join" the lines with filenames with lines with versions and commands? What *would* you do!?


It could be anything on the line with the filename on it, but you want to say globally search for "whatever" (conf) in this case, and do the ex/ed command "j" on it which joins it with the next line.


Transform XML output of cvs2cl ( into the format required for a promotion request. --xml gives you all the data and metadata you need.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki