Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Though we were instructed not to, a colleague of mine used vi to view a large text file (server.log 3.5 GB). This filled up /var/tmp and caused some problems on the server.

What caused this? Why shouldn't we use vi for large files?

share|improve this question
vi (or vim for that matter) is damn slow on large files and may be even unusable if there are not many line ends. Furthermore, the file needs to fit into the memory. Use less for large files, it's much faster and often sufficient for reading/watching log files. – Marco Dec 19 '13 at 12:41
@Marco Why not put it as an answer? – Bernhard Dec 19 '13 at 12:43
because it's not the answer to the question, but a comment, the quesiton is "What caused this? Why shouldn't we use vi for large files?" – Kiwy Dec 19 '13 at 12:46
look at comment with my answer. – Raja Dec 19 '13 at 15:36
up vote 7 down vote accepted

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

some times you may get ,you will receive the following error message like this also

Not enough space in /var/tmp.

You can read about how to fix this here: http://kb.iu.edu/data/akqv.html

share|improve this answer
"vi editing buffer needs space equal to roughly twice the size of the file with which you are working" Source? – atripathi Dec 19 '13 at 15:25
long ago I have read from kb.iu.edu/data/akqv.html. so i gave it to you – Raja Dec 19 '13 at 15:36

Vim was not designed for large files. It has certain features which drastically slow down the user experience. For instance, it loads the file into memory which basically limits to edit files smaller than your memory size. Furthermore, features such as syntax highlighting, swap file and undo are very inefficient with large files and slow thing down even more. Another issue is that vim expects not too long lines. If a file contains few newline characters vim becomes unusable.

That having said, there are plugins like vim-largefile that change particular settings to be more efficient with large files, but in the end vim will never be snappy when you throw several GiBs at it.

The bottom line is, don't use vim on large files. If you want to view (in contrast to edit) large files, use less. If you want to search for a pattern, ues a slash to start a search a pattern:

/<pattern>  # forward search
?<pattern>  # backward search

If you want to filter the output use an ampersand:


Then start the continuous output using shift-f. You can exit the continuous output display with ctrl-c and refine or cancel your filter pattern or start a search.

To edit large files use tools like sed, they are efficient and designed for this very purpose.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.