[sf-lug] file limit in vi?

Rick Moen rick at linuxmafia.com
Wed Sep 26 11:48:20 PDT 2007


Quoting Alden Meneses (aldenm at gmail.com):

> I am trying to vi a 92MB file but it complains that there are too many lines
> in the file. Is there another utility I can use to modify the file? I am
> using AIX.

Limits in "vi" depend, by the way, on which implementation you're using:

primodial BSD-derived vi
nvi
vim
elvis
(etc.)

The most common variants on modern Linux systems are vim and nvi, in
that order.  On *BSD, the same, except reverse order.  

The _actual_ internal limits in vim, per se, appear to be 2GB on 32-bit 
machines, and vastly, vastly longer on 64-bit machines with 64-bit long
integers.  You can set vim variable "linelimit" to 2147483647 lines 
to set the the maximum number of lines that vim is _willing_ to open
to enable loading of up to 2GB files on 32-bit machines.  That might
well be your immediate problem.

Note that you are potentially limited by disk space available to the
swapper.

Line length is also limited to 2147483647 characters on OSes with 32-bit 
integers.

The vim docs add this, about memory usage limits:

The option 'maxmem' ('mm') is used to set the maximum memory used for
one buffer (in kilobytes).  'maxmemtot' is used to set the maximum
memory used for all buffers (in kilobytes).  The defaults depend on the
system used.  For the Amiga and MS-DOS, 'maxmemtot' is set depending on
the amount of memory available.  If you don't like Vim to swap to a
file, set 'maxmem' and 'maxmemtot' to a very large value.  The swap file
will then only be used for recovery.  If you don't want a swap file at
all, set 'updatecount' to 0, or use the "-n" argument when starting Vim.
Note that the 'maxmem' option is only used when a buffer is created.
Changing this option does not affect buffers that have already been
loaded.  Thus you can set it to different values for different files.
'maxmemtot' works always.

I used to have the corresponding nvi information handy, e.g., in 2005,
when I answered a similar question on Usenet:
http://www.webservertalk.com/message1218263.html

(Which please see, including the spectacle of Usenet troll Alan Connor
trying to bait me about not using "the real vi", and failing.)





More information about the sf-lug mailing list