Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
What is the largest file I can edit using vim?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  21 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
cellurl  
View profile  
 More options Jun 6 2012, 9:16 pm
From: cellurl <gpscru...@gmail.com>
Date: Wed, 6 Jun 2012 18:16:58 -0700 (PDT)
Local: Wed, Jun 6 2012 9:16 pm
Subject: What is the largest file I can edit using vim?
I have a 4GB text file.
Q: Can I use vim to edit it?
If not, any suggestions?

thanks for publishing vim ;-)

-cellurl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam  
View profile  
 More options Jun 7 2012, 12:09 am
From: Adam <les...@gmail.com>
Date: Wed, 6 Jun 2012 23:09:26 -0500
Local: Thurs, Jun 7 2012 12:09 am
Subject: Re: What is the largest file I can edit using vim?

For a file that large you'll need to make sure you have a lot of ram and
are using a 64 bit version of vim.  You should also consider using the
LargeFile plugin (http://www.vim.org/scripts/script.php?script_id=1506)

~Adam~


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
james pruett  
View profile  
 More options Jun 7 2012, 12:22 am
From: james pruett <gpscru...@gmail.com>
Date: Wed, 6 Jun 2012 23:22:40 -0500
Local: Thurs, Jun 7 2012 12:22 am
Subject: Re: What is the largest file I can edit using vim?

ok, I dont have a 64bit system.
Thanks for the reply.

--------------------------
[Speederaser] may be the best automotive accessory since the radar
detector<http://www.motorauthority.com/news/1068165_an-android-app-for-cruise-...>
.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin O'Gorman  
View profile  
 More options Jun 7 2012, 12:53 am
From: "Kevin O'Gorman" <kogor...@gmail.com>
Date: Wed, 6 Jun 2012 21:53:38 -0700
Local: Thurs, Jun 7 2012 12:53 am
Subject: Re: What is the largest file I can edit using vim?
Reorganized to bottom-posted replies.

> On Wed, Jun 6, 2012 at 11:09 PM, Adam <les...@gmail.com> wrote:

>> For a file that large you'll need to make sure you have a lot of ram and
>> are using a 64 bit version of vim.  You should also consider using the
>> LargeFile plugin (http://www.vim.org/scripts/script.php?script_id=1506)

>> ~Adam~

>> --
>> You received this message from the "vim_use" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visit http://www.vim.org/maillist.php
On Wed, Jun 6, 2012 at 9:22 PM, james pruett <gpscru...@gmail.com> wrote:
> ok, I dont have a 64bit system.
> Thanks for the reply.

In which case, you could chop the file into segments and edit those.
Or, depending on what you're trying to do, you might be able to write
a program to make your changes.

I have to say that even editors that *can* handle huge files tend to
do so very slowly.  There may be exceptions, but I wouldn't count on
it.

--
Kevin O'Gorman, PhD


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marc Weber  
View profile  
 More options Jun 7 2012, 2:37 am
From: Marc Weber <marco-owe...@gmx.de>
Date: Thu, 07 Jun 2012 08:37:07 +0200
Local: Thurs, Jun 7 2012 2:37 am
Subject: Re: What is the largest file I can edit using vim?
Talk about what you want to do with such a big file an people will try
to find a solution. Editing 4GB files in a text editor is no joy
anyway.

Marc Weber


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
james pruett  
View profile  
 More options Jun 7 2012, 9:56 am
From: james pruett <gpscru...@gmail.com>
Date: Thu, 7 Jun 2012 08:56:19 -0500
Local: Thurs, Jun 7 2012 9:56 am
Subject: Re: What is the largest file I can edit using vim?

I have an *.sql file.
Typically I chop it, but I am tired of chopping it.
I want to remove the first 10 lines and the last 10 lines of this 4GB file.
I have had no success with UltraEdit and VI, gedit, wordpad, VIM.
I may try google-docs....

Thanks for publishing vim!
-cellurl

--------------------------
[Speederaser] may be the best automotive accessory since the radar
detector<http://www.motorauthority.com/news/1068165_an-android-app-for-cruise-...>
.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Amit Agarwal  
View profile  
 More options Jun 7 2012, 10:12 am
From: Amit Agarwal <a...@amit-agarwal.com>
Date: Thu, 07 Jun 2012 19:42:13 +0530
Local: Thurs, Jun 7 2012 10:12 am
Subject: Re: What is the largest file I can edit using vim?
You can possibly use sed to do that.

--
Sent from my Nokia N900


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Fritz  
View profile  
 More options Jun 7 2012, 10:23 am
From: Ben Fritz <fritzophre...@gmail.com>
Date: Thu, 7 Jun 2012 07:23:01 -0700 (PDT)
Local: Thurs, Jun 7 2012 10:23 am
Subject: Re: What is the largest file I can edit using vim?

On Thursday, June 7, 2012 8:56:19 AM UTC-5, cellurl wrote:
> I have an *.sql file.
> Typically I chop it, but I am tired of chopping it.
> I want to remove the first 10 lines and the last 10 lines of this 4GB file.

The "head" and "tail" unix commands seem designed exactly for such things.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reid Thompson  
View profile  
 More options Jun 7 2012, 10:27 am
From: Reid Thompson <Reid.Thomp...@ateb.com>
Date: Thu, 7 Jun 2012 14:27:23 +0000
Local: Thurs, Jun 7 2012 10:27 am
Subject: Re: What is the largest file I can edit using vim?

On Thu, 2012-06-07 at 19:42 +0530, Amit Agarwal wrote:
> You can possibly use sed to do that.

from the sed one liners page http://sed.sourceforge.net/sed1line.txt

# delete the first 10 lines of a file
 sed '1,10d'

 # delete the last line of a file
 sed '$d'

 # delete the last 2 lines of a file
 sed 'N;$!P;$!D;$d'

 # delete the last 10 lines of a file
 sed -e :a -e '$d;N;2,10ba' -e 'P;D'   # method 1
 sed -n -e :a -e '1,10!{P;N;D;};N;ba'  # method 2


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marc Weber  
View profile  
 More options Jun 7 2012, 10:28 am
From: Marc Weber <marco-owe...@gmx.de>
Date: Thu, 07 Jun 2012 16:28:37 +0200
Local: Thurs, Jun 7 2012 10:28 am
Subject: Re: What is the largest file I can edit using vim?
forgett about vim, on linux just do:
tail -n +10 file.sql  | head -n +10 > trimmed.sql

Marc Weber


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "An easier way to top & tail 4GB [Was: What is the largest file I can edit using vim?]" by Erik Christiansen
Erik Christiansen  
View profile  
 More options Jun 7 2012, 10:30 am
From: Erik Christiansen <dva...@internode.on.net>
Date: Fri, 8 Jun 2012 00:30:18 +1000
Local: Thurs, Jun 7 2012 10:30 am
Subject: An easier way to top & tail 4GB [Was: What is the largest file I can edit using vim?]
On 07.06.12 08:56, james pruett wrote:

> I have an *.sql file.
> Typically I chop it, but I am tired of chopping it.
> I want to remove the first 10 lines and the last 10 lines of this 4GB file.

$ tail --lines=+11 fred.sql | head --lines=-10

(Tested with /etc/passwd, it cuts at the right line numbers, as far as I
can see.)

Erik

--
"When the only tool you have is a hammer, you tend to treat everything as if  
it were a nail."                                                              
                                                          - Abraham Maslow


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "What is the largest file I can edit using vim?" by Tony Mechelynck
Tony Mechelynck  
View profile  
 More options Jun 7 2012, 11:37 am
From: Tony Mechelynck <antoine.mechely...@gmail.com>
Date: Thu, 07 Jun 2012 17:37:53 +0200
Local: Thurs, Jun 7 2012 11:37 am
Subject: Re: What is the largest file I can edit using vim?
On 07/06/12 03:16, cellurl wrote:

> I have a 4GB text file.
> Q: Can I use vim to edit it?
> If not, any suggestions?

> thanks for publishing vim ;-)

> -cellurl

There are two kinds of limits:

1. Your processor must be able to address a single data-memory space
larger than the file.

See ":help limits" for 16- and 32-bit processors. 64-bit processors can
typically address all your installed RAM and swap memory as one linear
address space: see 2 below. (N.B. 2^63 = approx. 9.22e18)

2. Your total installed RAM and swap space must be larger than the file
+ the resident Vim code + whatever else you're running in parallel.

The largest file you can edit depends on the smaller of the limits
defined by 1 and 2 above.

Notes:
- It's no use having more installed memory than your processor can address;
- It's usually recommended not to have more swap than twice your
installed RAM. (Using swap too much might bring the system to the point
where all it's doing is waiting for disk heads to move to the right
record of your swapfile or swap partition. I've had the case, for
instance when linking the libxul of a Mozilla application at the end of
an own-compile in order to test a bugfix before landing it.)

Best regards,
Tony.
--
FATHER:       Make sure the Prince doesn't leave this room until I come and
               get him.
FIRST GUARD:  Not ... to leave the room ... even if you come and get him.
FATHER:       No.  Until I come and get him.
SECOND GUARD: Hic.
                  "Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dominique Pellé  
View profile  
 More options Jun 7 2012, 12:49 pm
From: Dominique Pellé <dominique.pe...@gmail.com>
Date: Thu, 7 Jun 2012 18:49:02 +0200
Local: Thurs, Jun 7 2012 12:49 pm
Subject: Re: What is the largest file I can edit using vim?

Marc Weber <marco-owe...@gmx.de> wrote:
> forgett about vim, on linux just do:
> tail -n +10 file.sql  | head -n +10 > trimmed.sql

Many people posted solutions with head and tail that don't work.

Here is one that works:

$ sed 1,10d < input.txt | tac | sed 1,10d | tac > output.txt

Here is another one, faster but uglier:

$ perl -ne 'print $l[$.%10] if ($. >= 10*2); $l[$.%10] = $_' input.txt

> output.txt

-- Dominique

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Fritz  
View profile  
 More options Jun 7 2012, 12:57 pm
From: Ben Fritz <fritzophre...@gmail.com>
Date: Thu, 7 Jun 2012 09:57:49 -0700 (PDT)
Local: Thurs, Jun 7 2012 12:57 pm
Subject: Re: What is the largest file I can edit using vim?

On Thursday, June 7, 2012 11:49:02 AM UTC-5, Dominique Pelle wrote:
> Marc Weber <marco-owe...@gmx.de> wrote:

> > forgett about vim, on linux just do:
> > tail -n +10 file.sql  | head -n +10 > trimmed.sql

> Many people posted solutions with head and tail that don't work.

Just curious...I've never used head or tail. But why won't they work in this situation? This seems like exactly what they're meant to accomplish; retrieving only a specific part of a file.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "An easier way to top & tail 4GB [Was: What is the largest file I can edit using vim?]" by Kevin O&#39;Gorman
Kevin O'Gorman  
View profile  
 More options Jun 7 2012, 1:18 pm
From: "Kevin O'Gorman" <kogor...@gmail.com>
Date: Thu, 7 Jun 2012 10:18:04 -0700
Local: Thurs, Jun 7 2012 1:18 pm
Subject: Re: An easier way to top & tail 4GB [Was: What is the largest file I can edit using vim?]
On Thu, Jun 7, 2012 at 7:30 AM, Erik Christiansen

<dva...@internode.on.net> wrote:
> On 07.06.12 08:56, james pruett wrote:
>> I have an *.sql file.
>> Typically I chop it, but I am tired of chopping it.
>> I want to remove the first 10 lines and the last 10 lines of this 4GB file.

I'm not sure what you mean by chopping it, or why it would be
tiresome.  There are utilities for such things, like split(1).

> $ tail --lines=+11 fred.sql | head --lines=-10

> (Tested with /etc/passwd, it cuts at the right line numbers, as far as I
> can see.)

Also a skillful technique.

--
Kevin O'Gorman, PhD


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "What is the largest file I can edit using vim?" by Gary Johnson
Gary Johnson  
View profile  
 More options Jun 7 2012, 1:43 pm
From: Gary Johnson <garyj...@spocom.com>
Date: Thu, 7 Jun 2012 10:43:15 -0700
Local: Thurs, Jun 7 2012 1:43 pm
Subject: Re: What is the largest file I can edit using vim?
On 2012-06-07, Dominique Pell wrote:

> Marc Weber wrote:

> > forgett about vim, on linux just do:
> > tail -n +10 file.sql | head -n +10 > trimmed.sql

> Many people posted solutions with head and tail that don't work.

> Here is one that works:

> $ sed 1,10d < input.txt | tac | sed 1,10d | tac > output.txt

Are you sure that tac works in this case?  I thought that tac pushed
all the input lines onto a stack in memory, then popped each line as
it was output.  That means having to put the entire file into
memory, which we were trying to avoid.

Regards,
Gary


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dominique Pellé  
View profile  
 More options Jun 7 2012, 1:43 pm
From: Dominique Pellé <dominique.pe...@gmail.com>
Date: Thu, 7 Jun 2012 19:43:10 +0200
Local: Thurs, Jun 7 2012 1:43 pm
Subject: Re: What is the largest file I can edit using vim?

On Thu, Jun 7, 2012 at 6:57 PM, Ben Fritz <fritzophre...@gmail.com> wrote:
> On Thursday, June 7, 2012 11:49:02 AM UTC-5, Dominique Pelle wrote:
>> Marc Weber <marco-owe...@gmx.de> wrote:

>> > forgett about vim, on linux just do:
>> > tail -n +10 file.sql  | head -n +10 > trimmed.sql

>> Many people posted solutions with head and tail that don't work.

> Just curious...I've never used head or tail. But why won't they
> work in this situation? This seems like exactly what they're
> meant to accomplish; retrieving only a specific part of a file.

Because  tail  outputs the last n lines of a file, but what user
wanted is to remove the last lines.   So unless you know the
number of lines, you can't use tail.  But perhaps someone
can prove me wrong.

-- Dominique


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Jun 7 2012, 1:54 pm
From: Tim Chase <v...@tim.thechases.com>
Date: Thu, 07 Jun 2012 12:54:04 -0500
Local: Thurs, Jun 7 2012 1:54 pm
Subject: Re: What is the largest file I can edit using vim?
On 06/07/12 12:43, Dominique Pell wrote:

I think you're reading it backwards, as head/tail (at least GNU
versions; for other flavors, YMMV) allow for a "+" in front of the
number so

  tail -n +20

chops off the first 19 lines in the file; similarly, "-" in front of
the number with head does all but the N last lines of the file.  The
example above should likely read something like

  tail -n +11 file.sql | head -n -10 > trimmed.sql

(using a "-" instead of a "+" for head and incrementing the starting
point on tail).  There might be a fenceposting error there, but
that's the general gist.

-tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dominique Pellé  
View profile  
 More options Jun 7 2012, 2:19 pm
From: Dominique Pellé <dominique.pe...@gmail.com>
Date: Thu, 7 Jun 2012 20:19:44 +0200
Local: Thurs, Jun 7 2012 2:19 pm
Subject: Re: What is the largest file I can edit using vim?

Yes, I was wondering about that too.  But I checked and
tac only uses very little memory even on huge files.

Actually, tac behaves differently with an input file and with
an input stream:

* with an input file, it outputs results immediately. I suppose
  tac reads the file by block from the end of the file and reverse
  each blocks.
* with an input stream it can't do that, so it has to read the
  full stream before it can output. Yet it uses very little memory.
  It uses temporary files (confirmed by looking at /prof/<pid>/fd)

So tac solution works.  But given that tac is more efficient on
an input file than on an input stream, changing the order
should be better.  In other words, this...

$ tac input.txt | sed 1,10d | tac | sed 1,10d > output.txt

... should be faster than this:

$ sed 1,10d input.txt | tac | sed 1,10d | tac > output.txt

I measured it on a big file to confirm it:

first solution took 9.2 sec, second solution took 12.2 sec

In any case, the Perl solution that I gave and which use a
rotating buffer does one pass only, does not use much memory
and does not use temporary files either.

$ perl -ne 'print $l[$.%10] if ($. >= 10*2); $l[$.%10] = $_' input.txt

>output.txt

Yet this Perl solution is slower than tac.  It takes 14.8 sec on
the same input file.

The strange looking solution...

$ sed -e :a -e '$d;N;2,10ba' -e 'P;D' input.txt > output.txt

... takes 6.0 sec.

Tim Chase wrote:
> I think you're reading it backwards, as head/tail (at least GNU
> versions; for other flavors, YMMV) allow for a "+" in front of the
> number so

> tail -n +20

> chops off the first 19 lines in the file; similarly, "-" in front of
> the number with head does all but the N last lines of the file.  The
> example above should likely read something like

>  tail -n +11 file.sql | head -n -10 > trimmed.sql

Right. My apologies. That works indeed and it's much faster.
It does not have to parse line by line with this solution I suppose.
With the same large input as above, it only took 2.6 sec.

-- Dominique


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
james pruett  
View profile  
 More options Jun 8 2012, 10:57 am
From: james pruett <gpscru...@gmail.com>
Date: Fri, 8 Jun 2012 09:57:14 -0500
Local: Fri, Jun 8 2012 10:57 am
Subject: Re: What is the largest file I can edit using vim?

Google-docs won't handle a 4GB file...
So I will have to try unix tools...
http://support.google.com/docs/bin/answer.py?hl=en&answer=37603

On Thu, Jun 7, 2012 at 1:19 PM, Dominique Pellé
<dominique.pe...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Jun 8 2012, 12:43 pm
From: Tim Chase <v...@tim.thechases.com>
Date: Fri, 08 Jun 2012 11:43:01 -0500
Local: Fri, Jun 8 2012 12:43 pm
Subject: Re: What is the largest file I can edit using vim?
On 06/08/12 09:57, james pruett wrote:

> Google-docs won't handle a 4GB file...
> So I will have to try unix tools...

Then I recommend using "split" or "csplit".  The former can split on
bytes/lines, while the latter can split on patterns.

-tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »