2

I have vim-markdown and nerdtree installed. And everything was working fine until I added the following to my .vimrc (verbatim from the nerdtree readme)

" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif

Now everytime I run the vim-markdown command :Toc I get the error:

Error detected while processing function <SNR>54_Toc[39]..BufWinEnter Autocommands for "*"..function 192[2]..193[4]..203[15]..function <SNR>54_Toc[39]..BufWinEnter Autocommands for "*"..func
tion 192[2]..193[4]..203:
line    6:
E788: Not allowed to edit another buffer now
Error detected while processing function <SNR>54_Toc[39]..BufWinEnter Autocommands for "*"..function 192[2]..193:
line    4:
E170: Missing :endfor

Note that this error is triggered independently of the nerdtree window being open or not.

I tracked the error using the :scriptnames command.

The relevant code to this error seems to come from vim-markdown/ftplugin/markdown.vim which has the following:

ugroup Mkd 
    " These autocmd calling s:MarkdownRefreshSyntax need to be kept in sync with
    " the autocmds calling s:MarkdownSetupFolding in after/ftplugin/markdown.vim.
    autocmd! * <buffer>
    autocmd BufWinEnter <buffer> call s:MarkdownRefreshSyntax(1)
    autocmd BufUnload <buffer> call s:MarkdownClearSyntaxVariables()
    autocmd BufWritePost <buffer> call s:MarkdownRefreshSyntax(0)
    autocmd InsertEnter,InsertLeave <buffer> call s:MarkdownRefreshSyntax(0)
    autocmd CursorHold,CursorHoldI <buffer> call s:MarkdownRefreshSyntax(0)
augroup END

But surprisingly it doesn't make a difference if I comment the ButWinEnter line in it.

I found a couple of relevant threads here and here But can't really make something out of it that I can use to fix my problem.

Thanks in advance for any help.

2 Answers 2

0

I met the same problem.
but for me, commenting the line blow works.

" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif

Maybe you should restart vim after commenting.

Otherwise, you can use vim-nerdtree-tabs to archive same result.

0

I had the same problem with RipGrep and NERDTree, the same error happened when I tried to use the :Rg command. It was caused by BufWinEnter in the Quickfix buffer, so I fixed that by excluding it :

autocmd BufWinEnter * if getcmdwintype() == '' && &buftype != 'quickfix' | silent! NERDTreeMirror | endif

Not sure if it's the same problem for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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