For example, I use two very popular plug-ins, NERDTree and Tagbar, in vim. Generally, I will open these two plug-ins at the same time after opening the editor. It is very troublesome to type twice every time. I want to be able to They cannot be combined into one command, such as dev
, to achieve the following effect, I enter
:dev php
It will execute the two commands NERDTree php
and Tagbar
by default. The php here is one of my Bookmark
names.
天蓬老师2017-05-16 16:44:58
Write a function.
func! Devphp() if &filetype == 'php' exec "NERDTree" exec "Tagbar" endif endfunc :command -range=% DEVPHP :call Devphp()
The code has not been tested, please modify it yourself.
In addition, for nerdtree, you can set it to be opened by default:
autocmd vimenter * NERDTree
过去多啦不再A梦2017-05-16 16:44:58
I don’t quite understand how you open the plug-in, but you can probably do it with map. For example, this is how I compile C/C++. For reference
map <F8> <esc>:w!<cr>:!g++ -o %< % -Wall<cr>