Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim configuration to turn on syntax for .conf files

Tags:

vim

I have a config file under my python project, called "logging.conf", the file looks like:

[formatters] keys: console, logging  [formatter_console] format: %(asctime)s | %(message)s  [formatter_logging] format: %(message)s  etc etc etc 

Tried :syntax on, nothing happened, the .conf files look very plain. Is there anyway I can turn on some syntax to make the .conf file more colorful and readable?

like image 567
Shengjie Avatar asked May 02 '13 12:05

Shengjie


People also ask

How do I enable syntax in Vim?

To enable Syntax Highlighting feature in VI editor, open the file called /etc/profile. Add the alias function to VI by pointing to VIM in /etc/profile file. This file is used to set alias functions globally. If you would like to set user specific aliases and functions, then you need to open the file .

How do I set default syntax in Vim?

Add the text, “syntax on” anywhere in the file to enable syntax highlighting permanently for vim editor. Save and close the file by typing ':x'. For disabling the feature, just re-open . vimrc file, change the text “syntax on” to “syntax off” and save the file.

Where are Vim syntax files?

vim/syntax/ folder, they cannot be loaded from anywhere else. So even though syntax/python. vim comes bundled with Vim and is available in /usr/share/vim/vim72/syntax/python. vim , if an alternative version is instead loaded from ~/.


1 Answers

You can check vim.org or the Internet for a suitable syntax.

As a first approximation, this somewhat looks like DOS / Windows INI files. Vim comes with a syntax for them; try

:setf dosini 

If that suits you, you can add a filetype detection rule:

:autocmd BufRead,BufNewFile logging.conf setf dosini 

See :help ftdetect for details.

like image 89
Ingo Karkat Avatar answered Sep 28 '22 06:09

Ingo Karkat