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 /var/tmp directory
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:
cd directory
vi
:set directory=/tmp
:e filename
In the above example, replace
directorywith the directory that contains the file you wish to edit, andfilenamewith 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.,
less,head, ortail). Althoughlessis the opposite ofmore, 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 usingless, enter: less --helpTo look at a specified number of lines at the top and bottom of a file, use the
headandtailcommands, respectively. For information onheadandtail, 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 filenameIn the above example, replace
lineswith the number of lines you wish in each file, andfilenamewith the name of the file. - On the Indiana University Research Database
Complex (RDC),
/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/tmpYou 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 themanpage for-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.







