Reload file in vim [duplicate]
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?
Solution 1:
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.
Solution 2:
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 F
orward, 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 :e
ing in vim.