LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-26-2008, 09:23 PM   #1
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Squeeze, CrunchBang Waldorf
Posts: 516

Rep: Reputation: 38
Vim: How do I read lines of text into a buffer


I would like to read lines from a text file into a file I am editing in Vim. I can read a file in :r file, but don't know how to read in certain lines from the file.

I have been looking through the internet and at some tutorials, but am not finding out how to do this.

Thanks.
 
Old 05-26-2008, 10:20 PM   #2
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
Vi will allow you to execute a command and read in the output of the command, you
can use this with sed to read in the lines, in this example, sed will print lines
3,4,5,6, from the sourcefile and add them to your vi buffer.

Quote:
:r! sed --quiet "3,6 p" sourcefile
 
  


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
Vim: How to hide commentary lines brianmcgee Programming 1 04-14-2008 09:15 AM
comment multiple lines in vim Furlinastis Slackware 9 12-11-2007 01:01 PM
Read specific lines from a text file chobin Programming 8 06-14-2006 11:14 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
bash script that can read lines of text palceksmuk Programming 1 12-25-2005 03:49 AM


All times are GMT -5. The time now is 04:47 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration