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?

  • 3
    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, 2013 at 12:41
  • @Marco Why not put it as an answer?
    – Bernhard
    Dec 19, 2013 at 12:43
  • 1
    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, 2013 at 12:46
  • look at comment with my answer.
    – Raja G
    Dec 19, 2013 at 15:36

2 Answers 2


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.


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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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