LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2012, 04:52 AM   #1
bison72
LQ Newbie
 
Registered: May 2012
Posts: 8

Rep: Reputation: Disabled
Concatenate multiple data in vi


Hi there, I have an issue in concatenating data in vi. Let's say initially the lines are shown as below:

123
abc
xyz
456

321
def
xyz
456

and I want something like this:

123321
abcdef
xyzxyz
456456

Can anyone help me with this? Thanks a lot!
 
Old 08-13-2012, 03:41 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
Not sure if it works in straight vi, but I can do it in vim. Just use the block selection tool (ctrl+v), to highlight and 'd' the second block. Then move up to the end of the first line and simply 'p' paste it.

Of course this depends on there being two blocks of text that line up. If you're actually trying to do something fancier like concatenate line n with line n+m, then you'll have to do something like record a macro or write a script.

http://vim.wikia.com is a good place for looking up vim how-to stuff.
 
Old 08-13-2012, 09:11 PM   #3
bison72
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
This is quite helpful. Thank you very much David!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mput multiple data using for loop divyashree Programming 3 07-14-2012 10:09 AM
concatenate multiple patches into one file bryanvick Linux - Software 1 11-07-2011 01:36 PM
piping data to multiple outputs wjtaylor Linux - General 3 03-29-2011 09:34 PM
concatenate data from different lines kiloman Linux - General 1 03-01-2011 08:15 AM
Issues with multiple data types (C/C++) R00ts Programming 2 11-16-2005 09:37 PM


All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration