在vim中重新加载文件

mcg*_*er5 54 vim

当我在 vim 中打开一个文件时,在这种情况下是一个日志文件,我想触发刷新并将任何文件更改加载到我现有的 vim 会话中。

我经常在日志文件上使用 tail -f ,但是当我使用 java 和 tomcat 时,日志消息对于 tail 来说太多了...

是否有 vim 命令来重新加载打开的文件?

Den*_*son 74

试试这个:

:e
Run Code Online (Sandbox Code Playgroud)

来自:h :e

编辑当前文件。当在 Vim 之外更改当前文件时,这对于重新编辑当前文件很有用。


小智 15

虽然:e是您提出的问题的正确答案,但如果目标是跟踪具有良好回滚的日志,则可以使用较少的内容。F查看文件时将F向前滚动,并不断重新加载。从手册页:

   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.)
Run Code Online (Sandbox Code Playgroud)

:e在 vim 中快速ing相比,对用户的强加更少。