Ⅰ. 插件描述
create user-defined operator mappingsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/omap-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/omap-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/omap-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/Omap.vim
Ⅳ. 文档说明
A slightly more maintained version of this script is here: https://github.com/bencollerson/Omap.vim
Omap.vim provides the :Omap command, among others, which creates user-defined operator commands (like y c d and g?, see :help operator for more info).
To demonstrate, this command can be used to add functionality to other scripts. You can use Omap.vim in conjuction with EnhancedCommentify.vim (vimscript #23) to create a commenting operator. Assuming both EnhancedCommentify.vim and Omap.vim are installed in your vim plugin directory, add the following commands to your .vimrc file:
let g:EnhCommentifyUserBindings = 'yes'
runtime plugin/Omap.vim
Omap <silent> <unique> <leader>c <Plug>Commentj
Omap <silent> <unique> <leader>u <Plug>DeCommentj
This will stop the default mappings being defined by EnhancedCommentify.vim and in their place create comment (c) and uncomment (u) operators.
This allows commenting to be carried out over areas defined by vim motions and text objects. For example:
cc -- comments a line
. -- comments the next line (repeats last command)
3cc -- comments three lines
uu -- uncomments a line
c4j -- comments the current line and the four following lines
caB -- comments a block of code
Note that the dot (.) command (see :help .) works to repeat Omaps even though they are mappings. A command, :DotCommandSet, is defined by Omap.vim which allows other mappings to similarly be repeated using the dot command.
For more detailed help see the help documentation in the archive below.