vim-watch_for_changes


Ⅰ. 插件描述

Make vim ultra sensitive about external changes to files

Ⅱ. 基本信息

创建日期:  2013-08-09
使用用户:  1
Github星:  1
插件作者:  Gabriel Fortuna

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'gee-forr/vim-watch-for-changes'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'gee-forr/vim-watch-for-changes'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'gee-forr/vim-watch-for-changes'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/gee-forr/vim-watch_for_changes

Ⅳ. 文档说明

vim-watch_for_changes

Make vim ultra sensitive about external changes to files

Note:

This is not my vim script. I've taken it from a very helpful page on the Vim wiki.

I've merely turned it into a plugin so that it plays nicely with Vundle. I was previously manually loading it with an absolute path via Vundle, and it was breaking for other people that used my vim config, of which there are a couple

Instructions:

If you are using a console version of Vim, or dealing
with a file that changes externally (e.g. a web server log)
then Vim does not always check to see if the file has been changed.
The GUI version of Vim will check more often (for example on Focus change),
and prompt you if you want to reload the file.

There can be cases where you can be working away, and Vim does not
realize the file has changed. This command will force Vim to check
more often.

Calling this command sets up autocommands that check to see if the
current buffer has been modified outside of vim (using checktime)
and, if it has, reload it for you.

This check is done whenever any of the following events are triggered:

  • BufEnter
  • CursorMoved
  • CursorMovedI
  • CursorHold
  • CursorHoldI

In other words, this check occurs whenever you enter a buffer, move the cursor,
or just wait without doing anything for 'updatetime' milliseconds.

Normally it will ask you if you want to load the file, even if you haven't made
any changes in vim. This can get annoying, however, if you frequently need to reload
the file, so if you would rather have it to reload the buffer without
prompting you, add a bang (!) after the command (WatchForChanges!).
This will set the autoread option for that buffer in addition to setting up the
autocommands.

If you want to turn off watching for the buffer, just call the command again while
in the same buffer. Each time you call the command it will toggle between on and off.

WatchForChanges sets autocommands that are triggered while in any buffer.
If you want vim to only check for changes to that buffer while editing the buffer
that is being watched, use WatchForChangesWhileInThisBuffer instead.

添加新评论