Home Download Buy Blog Forum Support

INI file syntax definition

INI file syntax definition

Postby GreyWyvern on Fri Nov 13, 2009 3:48 pm

I made a generic INI file syntax highlighting package.

INI.tmLanguage.zip
Sublime Text INI file syntax highlight
(636 Bytes) Downloaded 2390 times


Image

Accounts for quoted property names and/or values containing "="

Image

Hope you can find it useful! :) Let me know if you have any suggestions.
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: INI file syntax definition

Postby Anomareh on Fri Nov 13, 2009 8:52 pm

Heh, I was just looking for one the other day. Ended messing with a version from the TM repository, though mines more for rainmeter. Not sure if you'd want to mess around with yours to make it good for that. My attempt was rather hackish as I'm not too experienced with regEx.
Anomareh
 
Posts: 222
Joined: Thu Oct 01, 2009 7:32 pm

Re: INI file syntax definition

Postby capnhud on Tue Sep 06, 2011 8:11 pm

I need to correct a problem with this file comments that begin with
; space comment

Code: Select all
; Enable the PHP scripting language engine under Apache.
engine = On
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.


show up as comments in my ini files but what do I edit in this files so that comments that start with
# space comment for example

Code: Select all
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server 4.1). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 4.1\my.ini"


shows up as actual comment in ST?

It appears that this
Code: Select all
^(;).*$\n?

controls the semicolon, but it also needs to include comments that begin with #
I tried
Code: Select all
^[#;].*$\n?
but that did not work

Nvrmnd: needed to open and close ST
capnhud
 
Posts: 62
Joined: Thu Jan 14, 2010 11:57 am

Re: INI file syntax definition

Postby AsherMaximum on Thu Mar 22, 2012 8:44 pm

Awesome, thanks.
Jon should add this to the next build.
I opened a UserEcho request for it here.
AsherMaximum
 
Posts: 7
Joined: Wed Apr 06, 2011 1:00 am

Re: INI file syntax definition

Postby hgraca on Fri Dec 07, 2012 10:10 am

Hi,

this seems to be what I want, but where do I put that xml file?

tkx
hgraca
 
Posts: 7
Joined: Fri Dec 07, 2012 10:09 am

Re: INI file syntax definition

Postby nandaabiz on Wed Dec 19, 2012 4:38 am

capnhud wrote:I need to correct a problem with this file comments that begin with
; space comment

Code: Select all
; Enable the PHP scripting language engine under Apache.
engine = On
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.


show up as comments in my ini files but what do I edit in this files so that comments that start with
# space comment for example

Code: Select all
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server 4.1). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 4.1\my.ini"


shows up as actual comment in ST?

It appears that this
Code: Select all
^(;).*$\n?

controls the semicolon, but it also needs to include comments that begin with #
I tried
Code: Select all
^[#;].*$\n?
but that did not work

Nvrmnd: needed to open and close ST



You may use
Code: Select all
^(;|#).*$\n?


It works for me ;)

Thanks to TS for making this one.
nandaabiz
 
Posts: 2
Joined: Wed Dec 19, 2012 4:34 am

Re: INI file syntax definition

Postby nandaabiz on Wed Dec 19, 2012 4:40 am

hgraca wrote:Hi,

this seems to be what I want, but where do I put that xml file?

tkx


Create a folder named "INI" in your-sublime-text-folder/Packages/
and put the extracted file "INI.tmLanguage" there.
nandaabiz
 
Posts: 2
Joined: Wed Dec 19, 2012 4:34 am

Re: INI file syntax definition

Postby AsherMaximum on Tue Mar 19, 2013 6:42 pm

Can the comment highlighting in this be modified to include comments that do not start on the beginning of the line?;
key = value ; tab key value comment

*edit: Upon further research I found that is not valid INI code. I did still want to be able to have a commented line that started with a space or tab, so I used another language file to come up with this:
Code: Select all
^\s*(;|#).*$\n?
instead of
Code: Select all
^(;).*$\n?
AsherMaximum
 
Posts: 7
Joined: Wed Apr 06, 2011 1:00 am

Re: INI file syntax definition

Postby robertcollier4 on Tue Mar 19, 2013 8:12 pm

http://en.wikipedia.org/wiki/INI_file#Comments - In some implementations, a comment may begin anywhere on a line, including on the same line after properties or section declarations. In others, including Windows' GetPrivateProfileString function, comments must occur on lines by themselves.


I prefer to follow this convention of allowing semicolon comments anywhere on the line. I have created a fork of clintberry sublime-text-2-ini package that includes syntax highlighting for comments anywhere on the line.
https://github.com/robertcollier4/sublime-text-2-ini

Or just view the diff of the changes made here.
Note: have also added the .reg extension to fileTypes detection - the INI syntax highlighting works great for Windows Registry Scripts as well.
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 18 guests