Ⅰ. 插件描述
CtrlP Extension that allows adding custom menus of commandsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'nmanandhar/vim-ctrlp-menu'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'nmanandhar/vim-ctrlp-menu'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'nmanandhar/vim-ctrlp-menu'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/nmanandhar/vim-ctrlp-menu
Ⅳ. 文档说明
# vim-ctrlp-menu
CtrlP Extension that allows adding custom menus of commands
We usually have a bunch of useful commands, but don't want to create a mapping for each of them.. Instead of a host of key mappings and commands and remembering them all, wouldn't it be more useful to have a single mapping/command for all the other commands?
Vim-Ctrp-Menu is a CtrlP extention that attempts to solve this problem by allowing you to create your own custom menu of commands. You can create as many menus as you like and you get all the goodness that Ctrp provides like fuzzy matching.

Prerequisite
You need to have CtrlP installed before you can use this plugin
Installation
Using Pathogen
cd ~/.vim/bundle
git clone https://github.com/nmanandhar/vim-ctrlp-menu.git
Defining Menus
This plugin uses the variable g:ctrlp_menus to define the menu. This variable should
be initialized in your vimrc to be a dictionary of menus
Structure of g:ctrp_menu_menus
let g:ctrlp_menus= {
\ "myMenuGroup1": {
\ "command1 for myMenuGroup1": 'echom "command1 of myMenuGroup1 executed"',
\ "command2 for myMenuGroup1": 'echom "command2 of myMenuGroup1 executed"'
\ },
\ "myMenuGroup2": {
\ "command1 for myMenuGroup2": 'echom "command1 of myMenuGroup2 executed"',
\ "command2 for myMenuGroup2": 'echom "command2 of myMenuGroup2 executed"'
\ }
\}Alternately, you can defined the same thing using a different syntax
let g:ctrlp_menus={}
let g:ctrlp_menus.myMenuGroup1=
\{
\ "command1 for myMenuGroup1": 'echom "command1 of myMenuGroup1 executed"',
\ "command2 for myMenuGroup1": 'echom "command2 of myMenuGroup1 executed"'
\}
let g:ctrlp_menus.myMenuGroup1={
\ "command1 for myMenuGroup2": 'echom "command1 of myMenuGroup2 executed"',
\ "command2 for myMenuGroup2": 'echom "command2 of myMenuGroup2 executed"'
\}Personally I prefer the second syntax because each menu group is defined separately.Note if your menu
group has a space in between, you will have to use the bracket notation
let g:ctrlp_menus["my menu group one "]={ ...Once the menu is defined and sourced, you can use CtrlpMenu command. By
default this command will combine all the commands and show them in CtrlP.
If you pass in the menu group, it will show only commands in that group.
Note in CommandMode, you also get completion of the MenuName. Press CtrlpMenu
followed by space followed by tab to get completion of menu names
Disabling the default menu
This plugin adds a default menu called default_menu. To disable this simply put the following in your vimrc
let g:ctrlp_use_default_menu = 0Mappings
By default, no mappings are provided. However it is recommened that you have a mapping to open up
the menus, since it is faily tedious to type CtrlpMenu on the command line
You can put something like the following in your vimrc file
nnoremap <leader>m :CtrlpMenu<cr>Since no menu group was passed, it will show all the commands in your menues.
Another possibility would be to use abbreviation in command mode to shorten the command
cabbrev menu CtrlpMenu