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 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 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.

  • To read large files without editing, use other commands that use fewer resources (e.g., 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. 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 head and tail commands, respectively. For information on head and 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 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.

  • On the Indiana University Research Database Complex (RDC), /var/tmp is 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 -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.

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.

This is document akqv in domains all and xsede-all.
Last modified on December 11, 2012.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.



Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.