I'm trying to use
autocmd to get some filename-specific mappings. I followed some instructions online and write the following thing in my
autocmd BufRead,BufNewFile special.txt (some mappings here)
It works fine when I enter a file or create a new buffer with the name
special.txt, but not when I create an empty buffer (for example, when starting vim with no argument) and save it with a name
Even a simple
echomsg won't work:
autocmd BufRead,BufNewFile special.txt echomsg test
and there's no text
test in message history.
But in the documentation of
BufRead I see
Also triggered for the filetypedetect group when executing ":filetype detect" and when writing an unnamed buffer in a way that the buffer gets a name.
When I save an empty buffer with the name
special.txt, the buffer gets a name and
BufRead should be triggered. But in fact it is not. Is there anything I'm missing, or I just have to use another autocommand event?
And in case it is useful, I'm using command line version of vim in the
vim-gtk package from Ubuntu repository.