hllau
hllau

Reputation: 10549

Enable Vim syntax highlighting regardless of filename extension

I am opening a file with no extension with vim, say:

myappsetting.conf

This file is actually a *.ini file, with following formats:

[setting_a]
yo = 1234

How can I enable vim to correctly display this file with colour with the correct format?

I am looking for some vim command like:

:set syntaxtype=ini

Thanks.

Upvotes: 6

Views: 7132

Answers (4)

iqmaker
iqmaker

Reputation: 2262

Work for me for *.conf, in .vimrc file:

au BufReadPost *.conf set syntax=dosini

Upvotes: 0

carlwgeorge
carlwgeorge

Reputation: 627

I was having the same issue on my Arch linux desktop. I found these files owned by the vim-runtime package.

$ pacman -Qlq vim-runtime | grep dosini
/usr/share/vim/vim74/ftplugin/dosini.vim
/usr/share/vim/vim74/syntax/dosini.vim

Based on that, I found I could get dosini highlighting either by setting the syntax (syn) or the filetype (ft).

:set ft=dosini

You can have this happen automatically with a vim modeline. Add this to the last line of your file.

# vim: set ft=dosini :

Upvotes: 7

kev
kev

Reputation: 161644

You can try this to reset the syntax:

:set syn=ini

Upvotes: 6

tUrG0n
tUrG0n

Reputation: 4448

Put this in your .vimrc :

au BufReadPost *.conf set syntax=ini

Upvotes: 8

Related Questions