6

Entering in vim

:au FileType netrw echom "ft is now netrw"

Afterwards, I open a netrw window with :E . Now, I expect to have a message entry in :messages. However, no message is there. Why is there no message?

According to "How to display line number in netrw?":

If you do anything based on an autocmd, it's likely that netrw is doing something as well and will overwrite whatever you did.

Afaik, this relates in particular to vim settings which have to be adjusted with g:netrw_bufsettings instead of au FileType netrw set nu.

My motivation for the question is tpope vinegar plugin which uses following autocmd:

augroup vinegar
  autocmd!
  autocmd FileType netrw call s:setup_vinegar()
augroup END

where I want to modify s:setup_vinegar(). However, my modification has no effect.

Update

To make the comment by Karl Yngve Lervåg more noticeable, I add the working unsilent version:

:au FileType netrw unsilent echom "ft is now netrw"
5

Your autocmd is clearly correct, as you can see that the message is printed if you explicitly set the 'ft' with setl ft=netrw.

The problem you are facing is that something is blocking the messages (such as :silent).

But your autocmd is being called when the filetype is first set; you can ensure that by using this:

au FileType netrw echom "ft is now netrw"|let var=1

After the :E . the variable var is being set.

If your problem is unrelated to echoing messages you can check variables instead of the output of :messages when you need to verify if your autocmd was executed. Otherwise you will need to follow the plugin code to find where the message is being suppressed.

  • Ah! Yes, you're right @mMontu! In Vim/vim74/auoload/netrw.vim there is the following line: sil! keepalt keepj doau FileType netrw. This will execute all ft netrw autocmds, but will do them silently! – Tumbler41 Jun 21 '16 at 18:49
  • @Tumbler41 Indeed, that was what I thought at first; but even after running :%s/\<sil\s*!\?//g on autoload/netrw.vim the messages were still hidden. But I didn't investigate further, as it is very likely that the OP was only trying to ensure the autocmd execution. – mMontu Jun 21 '16 at 18:54
  • 3
    You could try to unsilent the message as well... – Karl Yngve Lervåg Jun 21 '16 at 20:19
2

Update from Charles Campbell (the author of netrw). In response to my comment, "netrw executes all of its autocmd's silently." He states:

I've changed that in netrw v157h. Consider that change as experimental -- if I don't get complaints, it may stay that way. You can get v157h from my website: http://www.drchip.org/astronaut/vim/index.html#NETRW .

Regards, Chip Campbell

Here's the full context if you want it.

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.