Is it possible to access the NERDTree buffer in vimscript?

I am working on a plugin for NERDTree, which I asked about here .

I have a proof of concept plugin working on Github and pull request in NERDTree using interceptors. I need to edit the display lines.

The next thing I would like to get is to update the NERDTree buffer whenever the file is saved. I thought the NERDTree api function "NERDTreeRender ()" would be all I need - something like:

autocmd BufWrite * call NERDTreeRender()

will work, but it is called NERDTreeRender () in the buffer that was written, instead of NERDTree. Is there a way to run autocmd on bufwrite for this particular buffer? Launch: buffers in vim give me no indication that NERDTree has a numbered buffer, unfortunately.

Prevent autorun from writing to this particular buffer, does anyone have any other suggested methods?

+3
source share
1 answer

You can switch to the NERDTree buffer by setting switchbufto useopenand callingsbuf NERD*

Sort of:

autocmd BufWrite * call DoRender()

function! DoRender()
    set switchbuf+=useopen
    sbuf NERD*
    call NERDTreeRender()
endfunction
+1
source

All Articles