Reputation: 10386
BufReadCmd
is very useful for loading remote files, e.g. when you :e protocol://some/file.txt
The trick comes when you want to set filetype=text
after you finish BufReadCmd
. This is hard to do in the general case.
Ideally, all filetypes would be in ftplugin/filetype.vim
and you could (potentially) fix this by cycling filetype off | filetype on
. In practice, many filetypes are detected by the BufRead
event. Furthermore, many plugins add functionality to certain filetypes using the BufRead
event.
So if I want remote files to have the same functionality as local files I really need to fire the BufRead
event after I'm finished handling the BufReadCmd
event. How can I do this?
(Note: Yes, I know about scp and remote editing features. They can't be used here. I need something that works generally post-BufReadCmd
.)
Upvotes: 2
Views: 553
Reputation: 19475
You should be able to use the :doautocmd
command for that:
:doauto BufRead
You can also specify what file name should be used for pattern matching by the autocommands in case that differs from what vim would detect by itself.
Upvotes: 3