Tuesday, April 5, 2016

How to detect the file type in vimrc?

Greetings!

How does one detect the file type in .vimrc? AFAIU, 'filetype' setting is
not yet set when .vimrc is processed. The following check doesn't
work in .vimrc:

if &filetype==cpp
...

I want to distinguish between 'c' and 'cpp' for *.h files in which
the file type is specified in the modline. Is there a function which
can be called for reading the modline? I know that one can use autocmd,
when the file type read from the modline is already set, but is there a
way to get the modline variables in .vimrc?

Thanks,
Albert.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: