Reputation: 3933
How can I extend a command in vim?
I want to do it in two situations,
:diffget
or :diffput
I always want to run a :diffupdate
:NERDTreeToggle
I want to run a <C-w>=
Upvotes: 2
Views: 667
Reputation: 45107
I am unaware of any autocmd events that would be triggered for your scenarios. However a few custom mappings might be helpful.
You can change the default dp
and do
mappings to also do a :diffupdate
nnoremap dp dp:diffupdate<cr>
nnoremap do do:diffupdate<cr>
Note there are times where you cannot use dp
and/or do
and must use :diffput
/:diffget
. In these cases I would suggest you create a commands like so:
command! -nargs=? -range=1 -bar Diffput <line1>,<line2>diffput <args>|diffupdate
command! -nargs=? -range=1 -bar Diffget <line1>,<line2>diffget <args>|diffupdate
Or you can just map :diffupdate
nnoremap <f8> :diffupdate<cr>
NERDTree
nnoremap <leader>N :NERDTreeToggle<cr><c-w>=
Upvotes: 3
Reputation: 10311
Create your own custom function in VimScript in your .vimrc
that wraps several commands.
Here's one I use to launch a Clojure Repl in a buffer using several plugins:
fun! LeinCMD()
execute 'ConqueTerm lein repl'
execute 'set syntax=clojure'
execute 'normal! i'
endf
command! Repl call LeinCMD()
I then call this command with :Repl
(note that your custom commands must always start with an uppercase letter).
Source: Automate running several vim commands and keystrokes
Upvotes: 0