I have a tool opens files and forces a specific filetype. It launches vim with arguments along the lines of:
vim -c 'set filetype=foo' [file1 [file2 [...]]
This works fine for the first file, but just as you'd expect, this only works against the first file since it's the equivalent of changing the filetype once after launch. Every subsequent file on the command line picks up vim's default / autodetected filetype and not
foo. I can fix this with:
vim -c 'au BufRead * set filetype=foo"'
but this overrides all files, including ones I subsequently open, for example via
gf. Ideally I just want the identified files to be set to
foo, and nothing else. I'm not aware of any easy heuristic to detect the filetype by name or content, either: it's context sensitive (note I can't add a hint to the files, though they are usually constrained to one directory, if that helps).
Is there a way to set a default filetype for just the specified files? Failing that, is there another reasonably clean (i.e. I still want to be able to use vim normally in another window) way to approach it, for example some hack to override
ftdetect behaviour for one session?