When using vi to edit a large file, what should I do if I get the "not enough space" error message?
The default directory (
/var/tmp) for the vi
editing buffer needs space equal to roughly twice the size
of the file with which you are working, because vi uses the extra
lines for buffer manipulation. If the
does not have enough space for the editing buffer (e.g., you are
working with a large file, or the system is running out of space), you
will receive the following error message:
Not enough space in /var/tmp.
Following are some possible solutions:
- Choose another directory for vi's editing buffer:
In the above example, replace
directorywith the directory that contains the file you wish to edit, and
filenamewith the name of the file. The
/tmpin the third line is an example; you could use other scratch space as vi's editing buffer.
- To read large files without editing, use other commands that use
fewer resources (e.g.,
lessis the opposite of
more, it allows both backward and forward movement in the file. Also,
lessdoes not have to read the entire input file before starting; therefore, with large input files,
lessloads faster than vi. For information about using
less, enter: less --help
To look at a specified number of lines at the top and bottom of a file, use the
tailcommands, respectively. For information on
tail, see their respective man pages.
- Running vi on a file larger than 64 MB might generate an error,
depending on your system. To split a large file into smaller files
before editing in vi, use the
splitcommand split -l lines filename
In the above example, replace
lineswith the number of lines you wish in each file, and
filenamewith the name of the file.
- On the Indiana University Research Database
/var/tmpis usually on local disk (in contrast to being NSF-mounted like your home directory). Log into another node that has enough space (roughly twice the size of the file) in
/var/tmp, and then use vi to edit the file. To identify the amount of space left in
/var/tmp, use: df -k /var/tmp
You should get results similar to:Filesystem 512-blocks Free %Used Iused %Iused Mounted on /dev/hd9var 131072 75072 43% 836 6% /var
- Also, by default, vi on the RDC enforces an upper
limit of 1,048,560 lines. If your file has more lines than this,
change the default value by starting vi with the
-yNumberoption. Following is an excerpt from the
-yNumberon the RDC:
-yNumber overrides the maximum line setting of 1,048,560 with any value greater than 1024. You should request twice the number of lines that you require because the vi editor uses the extra lines for buffer manipulation.
At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?
This document was developed with support from National Science Foundation (NSF) grant OCI-1053575. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.
Last modified on December 11, 2012.