Ⅰ. 插件描述
Vim plugin: Alter the behavior of a command in modular wayⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'kana/advice'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'kana/advice'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'kana/advice'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/kana/vim-advice
Ⅳ. 文档说明
advice is a library for Vim scripts to provide a modular way to alter the
behavior of a command.
For example, if you want to change the default register for the command |C| to
"_ (|quote_|), you have to write a new operator then map |C| to execute the
operator, i.e., redefine the whole command. But how about if you also want to
change |C| in Visual mode to always behave as same as the default |C| in
|blockwise-visual| mode? How about if you want to disable one of the altered
behaviors afterwards? Therefore, redefining the whole command is not elegant
way.
ADVICE provides useful API to do such customization.
The concept of ADVICE is derived from the one of Emacs. See also:
http://www.gnu.org/software/emacs/elisp/html_node/Advising-Functions.html .
Note that there are some differences from the one of Emacs, especially: there
is no activation and ADVICE supports "usual" commands only (see
|advice-Normal-command|). Because Ex commands and functions cannot be
supported only by Vim script.
Requirements:
- Vim 7.2 or later
Latest version:
http://github.com/kana/vim-advice