ARCHIVED: 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.
To identify the amount of space left in /var/tmp
, use:
df -k /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 directory
with the directory that contains the file you wish to edit, and filename
with the name of the file. The /tmp
in the third line is an example; you could use other scratch space as vi's editing buffer.
less
, head
, or tail
). Although less
is the opposite of more
, it allows both backward and forward movement in the file. Also, less
does not have to read the entire input file before starting; therefore, with large input files, less
loads faster than vi.To look at a specified number of lines at the top and bottom of a file, use the head
and tail
commands, respectively.
split
command:split -l lines filename
In the above example, replace lines
with the number of lines you wish in each file, and filename
with the name of the file.
-yNumber
option, which overrides the maximum line setting. You should set the maximum to twice the number of lines you need, because vi uses the extra lines for buffer manipulation.At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.
This is document akqv in the Knowledge Base.
Last modified on 2019-06-18 14:45:26.