在vim中重新加载文件


53

这个问题已经在这里有了答案:

当我在vim中打开文件(在本例中为日志文件)时,我想触发刷新并将所有文件更改加载到我现有的vim会话中。

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

有vim命令重新加载打开的文件吗?


2
太多的尾巴?即使作为vim用户,我也看不到vim如何改善这种情况……
akira

太多的尾巴,因为行数是不可预测的,所以我不确定尾巴-fn 200是否足够
mcgyver5 2011年

我有一个由modsecurity生成的日志,其中包含非ASCII字符。在此文件上调用时,cat和tail都将锁定终端。Vim欢快地跳来跳去。

Answers:


71

试试看:

:e

来自:h :e

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


谢谢!我曾经想过:e并不是为我工作,但现在就可以了!
mcgyver5 2011年

或也转到文件结尾... :e | $
ebyrob

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.)

对用户的强制作用要比:e在Vim中快速投入强。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.