LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 09-14-2007, 11:48 AM   #1
tekmann33
Member
 
Registered: Nov 2006
Posts: 188

Rep: Reputation: 30
vim copy between files


I have a large email file that I want to split up into 4 or 5 different files. I considered using the split command, but this might segment certain emails in the list.

So, what I have done is determine where I want to segment the large file by line number. Using vim, I want to copy up to a certain line and paste into a separate file. When I use the yy command and specify the first "x" number of lines, it does not paste to the second file.

For instance, while in vim and in command mode, I type 118607yy and I receive a message that those lines have been yanked. I then go to the blank file and hit "p" but nothing pastes. I try to specify a register to yank these lines to, but when I open the second file and type "reg x" where x is the register I yanked the lines to, it doesn't display the yanked lines from the first file.

I have experimented with ym yy and "visual" mode but I can't seem to pull these lines.

Can anyone show me the commands I need to execute to do this?

Last edited by tekmann33; 09-14-2007 at 11:52 AM.
 
Old 09-14-2007, 12:10 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There's an easier way to do this using vi(m).

In command mode: : 1,100 w outfile

This will write lines 1 to 100 (including) to a file called outfile.

The first and last line of a file are special in vi(m). You can access them as . (dot) for the first line and $ for the last. So this: 50,$ w oufile2. will write lines 50 to end to a file called outfile2.

Hope this helps.
 
Old 09-14-2007, 01:02 PM   #3
tekmann33
Member
 
Registered: Nov 2006
Posts: 188

Original Poster
Rep: Reputation: 30
Thanks a bunch!
 
  


Reply



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
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
How to copy paste into VIM ? EAD Linux - Software 15 12-12-2006 06:38 PM
Buggy copy n paste with vim in terminal Kovacs Slackware 1 09-05-2006 12:13 AM
cygwin vim copy/paste problem takahaya Linux - Software 2 03-31-2006 01:16 AM
copy pasting from X app to vim Furlinastis Linux - General 3 12-05-2005 09:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:26 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
Open Source Consulting | Domain Registration