Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 05-26-2008, 10:23 PM   #1
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

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.

Old 05-26-2008, 11:20 PM   #2
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.

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


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

All times are GMT -5. The time now is 11:50 PM.

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