Vim 保存的文件未在网页上更新

Vim 保存的文件未在网页上更新

我正在尝试更新服务器上的 HTML 文件,但当我这样做时,它似乎没有更新,而是提供旧副本。我经历了按 :w 并按 Enter 键的通常过程(不是在插入模式下!:P),但仍然没有任何结果。

另外,每当我尝试编辑该文件时,我都会收到一条消息,指出 .swp 文件已被另一个进程使用,但我只打开了一个 bash shell(通过 PuTTY 连接)...

我尝试过硬重新加载并清理缓存,但无济于事。我已经在其他浏览器中尝试过,但没有帮助。

我还尝试删除所有交换文件并从记事本中存储的版本粘贴正确的文件,但该文件仍然不会更新。

有什么想法吗?

脚注:尝试编辑 .html 文件时收到的完整错误消息:

E325: ATTENTION
Found a swap file by the name ".index.html.swp"
          owned by: orderof3   dated: Mon Apr 25 04:48:09 2016
         file name: ~orderof3/public_html/Inviqa/TechPt1/index.html
          modified: no
         user name: orderof3   host name: e9.ehosts.com
        process ID: 66769
While opening file "index.html"
             dated: Mon Apr 25 11:32:56 2016
      NEWER than swap file!

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r index.html"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".index.html.swp"
    to avoid this message.

Swap file ".index.html.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

答案1

如果这是一个静态文件,很可能您的浏览器并未真正检索到新文件,您可以通过Shift在单击刷新时按 来检查(至少在 Firefox 中)。

如果这不起作用,则可能是您的网络服务器没有注意到更改,在这种情况下重新加载网络服务器通常就足够了。例如对于apache2

service  apache2 reload

或者

systemctl reload apache2.service

在极端情况下,您可能需要重新启动网络服务器。无论如何,:wvi保存文件时,如果vi遇到问题,它会通知您。

相关内容