Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

When I have a file open in vim, in this case a log file, I'd like to trigger a refresh and load any file changes into my existing vim session.

I often use tail -f on log files, but as I'm using java and tomcat, the log messages are too much for tail...

Is there a vim command to reload an open file?

share|improve this question

marked as duplicate by Canadian Luke, Nifle, Mike Fitzpatrick, DavidPostill, Raystafarian Dec 18 at 12:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
too much for tail? even as a vim user i dont see how vim can improve the situation ... –  akira Feb 17 '11 at 17:40
    
too much for tail in that the number of lines was unpredictable so I couldn't be sure that tail -f n 200 would be enough –  mcgyver5 Feb 17 '11 at 17:54
    
I've a log generated by modsecurity that contains non-ASCII characters. Both cat and tail lock the terminal when called on this file. Vim merrily chugs along. –  JS. Oct 12 at 17:15

2 Answers 2

up vote 37 down vote accepted

Give this a try:

:e

From :h :e:

Edit the current file. This is useful to re-edit the current file, when it has been changed outside of Vim.

share|improve this answer
    
thanks! I thought at one point :e wasn't working for me but it works now! –  mcgyver5 Feb 17 '11 at 17:52

While :e is the correct answer to the question you asked, if the goal is to tail a log with good scrollback, you can use less. F while viewing a file will scroll Forward, with continuous reloading. From the man page:

   F      Scroll  forward, and keep trying to read when the end of file
          is reached.  Normally this command would be used when already
          at the end of the file.  It is a way to monitor the tail of a
          file which is growing while it is being viewed.  (The  behav-
          ior is similar to the "tail -f" command.)

Less of an imposition on the user than rapidly :eing in vim.

share|improve this answer

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