Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

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 roughly twice the size of the file you are working with, since 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:

  • One approach is to choose a different directory as 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. The /tmp in the third line is an example; you could use other scratch space as vi's editing buffer. In the last line, replace filename with the name of the file you wish to edit.

  • To read large files without editing, you can use other commands that use fewer resources, such as less , head , and tail . Although less is the opposite of more , it allows both backward and forward movement in the file. Furthermore, less does not have to read the entire input file before starting; thus, with large input files, it starts up faster than vi. For information on how to use the less command, enter: less --help

    To look at a specified number of lines at the top and bottom of a file, use the head and tail commands. For more information on head and tail , see the man pages.

  • Running vi on a file larger than 64MB might generate an error, depending on your system. In that case, use the split command to split the large file into smaller files before editing in vi: split -l lines filename

    In the above example, replace lines with the number of lines you wish in each file, and replace filename with the name of the file you wish to split.

  • On the Research Database Complex (RDC) at Indiana University, since /var/tmp is usually on local disk (in contrast to being NSF-mounted like your home directory), you can simply log into a different node that has plenty of 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 the following command: df -k /var/tmp

    You should get results something like the following:

    Filesystem 512-blocks Free %Used Iused %Iused Mounted on /dev/hd9var 131072 75072 43% 836 6% /var
  • Also on the RDC at IU, by default, vi enforces an upper limit of 1,048,560 lines. If your file has more lines than this, you need to change this default value by starting vi using the -yNumber option. Following is an excerpt from the man page for -yNumber on 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."

This document was developed with support from the National Science Foundation (NSF) under Grant No. 0503697 to the University of Chicago and subcontracted to Indiana University. Additional support was provided by IU through its participation in the TeraGrid, which is supported by the NSF under Grants No. 0833618, SCI451237, SCI535258, and SCI504075. 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.

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 is document akqv in domains all and tgrid-all.
Last modified on June 30, 2009.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.