Tuesday, December 2, 2014

Re: syntax highlighting on files with no extension ?

On Tuesday, December 2, 2014 7:05:10 AM UTC-6, Ben Fritz wrote:
> On Monday, December 1, 2014 8:59:29 PM UTC-6, Alexander Chow wrote:
> > There is nothing I can do about it, I've made hundreds attempts without any luck.
> > How on earth can I set highlight on files that have no extension, say /etc/hosts file. I would like to set highlight on comments. that's it!!!
>
> Manually:
>
> :set filetype=hostconf
>
> or similar.
>
> Vim can also examine file content to determine the filetype. This should happen automatically for some files. In fact, by default if '#' is a comment in the first few lines in the file, you'll get a "conf" filetype.
>
> So, do you turn on automatic filetype detection in your .vimrc?
>
> If so, and it's still not working, then create a scripts.vim file in your user directory containing commands to inspect file contents to set the filetype, as detailed at :help new-filetype-scripts

Actually you probably don't need to even look at file content, for special files like /etc/hosts which are always in the same file path. For those you can use the easier/faster filename-based methods detailed in :help new-filetype.

--
--
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: