This question comes from here: https://github.com/tpope/vim-fugitive/issues/1586

In a word, I'm using the two plugins: Nerdtree and vim-fugitive. What I need is when I execute :Git checkout mybr, I want to make Nerdtree be refreshed automatically.

So tpope told me that I could use autocmd User FugitiveChanged.

This is the first time that I see autocmd User. It seems that User means "never execute automatically". So I've tried to manually execute this in my vim: :doautocmd User FugitiveChanged.

However, nothing happend: no error but Nerdtree hasn't be refreshed either.

Did I do something wrong?

2 Answers 2


User means it is never executed by core Vim. Basically, it's a plugin who does doautocmd User X. Your business is to catch it with :augroup / :autocmd. So, yes, you did it wrong.

  • Could you please show me how to catch it with :augroup/:autocmd?
    – Yves
    Oct 16, 2020 at 9:28

Here's my solution:

autocmd User FugitiveChanged  NERDTreeFocus | execute 'normal R' | wincmd p
  • 1
    Welcome to Vi and Vim! It would help if this answer explained the code more for future readers (you can edit to improve the answer).
    – D. Ben Knoble
    May 6 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.