You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the “Create file” method (keys m ↦ a), it seems that NERDtree first creates an empty file, and then opens the empty file. This creates and opens the file in Vim without triggering the BufNewFile event.
In particular, this breaks using the vim-templates plugin, please check the discussion on aperezdc/vim-template#17 for more details.
The text was updated successfully, but these errors were encountered:
@aperezdc, the fs_menu.vim NERDTree plugin is meant to be analogous to the file operations one would do by right-clicking in Windows Explorer. The difference here is between creating a file on disk first, and creating an empty buffer directly in vim. The latter triggers BufNewFile; whereas, opening a file will fire the BufReadPost. I took a look at the code for vim-template's TLoad function. It looks like it's already doing a check to make sure the buffer is empty. What happens if you modify the autocmd to trigger on BufReadPost also, like this?
if !g:templates_no_autocmd
augroup Templating
autocmd!
autocmd BufNewFile,BufReadPost * call <SID>TLoad()
augroup END
endif
The other option, as you mentioned is to write your own function using NERDTree's API.
When using the “Create file” method (keys
m
↦a
), it seems that NERDtree first creates an empty file, and then opens the empty file. This creates and opens the file in Vim without triggering theBufNewFile
event.In particular, this breaks using the
vim-templates
plugin, please check the discussion on aperezdc/vim-template#17 for more details.The text was updated successfully, but these errors were encountered: