Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open only the first few lines of a file in Vim

I'm working with a CSV that's just shy of 1 GB. I want to see the the file's structure and a sample of the data, but I don't want to open the entire file. How can I load the first few rows in Vim? If it makes a difference, I'm using MacVim.

like image 789
Joe Mornin Avatar asked Mar 21 '11 23:03

Joe Mornin


2 Answers

I generally use a command like head or tail for seeing partial content of large files.

$head -10 <large file>
like image 104
Vijay Avatar answered Sep 16 '22 11:09

Vijay


If you must do it from vim, use this:

:r !head -10 path/to/big.file

That would get the first 10 lines of big.file and insert them into the current buffer.

like image 35
Raimondi Avatar answered Sep 17 '22 11:09

Raimondi