Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create file (m ↦ a) does not trigger BufNewFile #617

Closed
aperezdc opened this issue Sep 11, 2016 · 1 comment
Closed

Create file (m ↦ a) does not trigger BufNewFile #617

aperezdc opened this issue Sep 11, 2016 · 1 comment

Comments

@aperezdc
Copy link

When using the “Create file” method (keys ma), 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.

@PhilRunninger
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants