JohnBeckett (talk | contribs) (Move in comment from talk page) |
JohnBeckett (talk | contribs) (Reword and merge in comments) |
||
Line 5: | Line 5: | ||
|created=August 19, 2007 |
|created=August 19, 2007 |
||
|complexity=basic |
|complexity=basic |
||
− | |author= |
+ | |author= |
|version=6.0 |
|version=6.0 |
||
|subpage=/200712 |
|subpage=/200712 |
||
Line 11: | Line 11: | ||
|category2=Syntax |
|category2=Syntax |
||
}} |
}} |
||
+ | Many programs store configuration information in text files with <tt>.ini</tt> extension ("dosini" file type). You can enable folding of dosini sections by placing a script in file <tt>~/.vim/after/syntax/dosini.vim</tt> on Unix-based systems, or in file <tt>$HOME/vimfiles/after/syntax/dosini.vim</tt> on Windows systems. |
||
− | Create file <tt>~/.vim/after/syntax/dosini.vim</tt> containing this line: |
||
− | |||
− | <pre> |
||
− | syn region dosiniSection start="^\[" end="\(\n*\[\)\@=" fold |
||
− | </pre> |
||
− | |||
⚫ | |||
− | {{Todo}} |
||
− | *Needs explanation. What does tip do? How do you use it? |
||
− | *Mention requirement for <tt>:set foldmethod=syntax</tt>. |
||
− | *Explain <tt>.vim</tt> directory and <tt>vimfiles</tt> on Windows. |
||
− | *The '*' in the ''end'' pattern should be replaced with '\+' so sections end only when '[' is after a newline. |
||
− | |||
− | ---- |
||
− | I have tried an improved version, which doesn't remove the syntax highlight of DOSINI format |
||
+ | The script should contain: |
||
<pre> |
<pre> |
||
syn region dosiniSection start="^\[" end="\(\n\+\[\)\@=" contains=dosiniLabel,dosiniHeader,dosiniComment keepend fold |
syn region dosiniSection start="^\[" end="\(\n\+\[\)\@=" contains=dosiniLabel,dosiniHeader,dosiniComment keepend fold |
||
setlocal foldmethod=syntax |
setlocal foldmethod=syntax |
||
+ | " Following opens all folds (remove line to start with folds closed). |
||
+ | setlocal foldlevel=20 |
||
</pre> |
</pre> |
||
+ | ==References== |
||
− | ---- |
||
+ | *{{help|folding}} |
||
+ | |||
⚫ |
Revision as of 10:22, 10 September 2008
Many programs store configuration information in text files with .ini extension ("dosini" file type). You can enable folding of dosini sections by placing a script in file ~/.vim/after/syntax/dosini.vim on Unix-based systems, or in file $HOME/vimfiles/after/syntax/dosini.vim on Windows systems.
The script should contain:
syn region dosiniSection start="^\[" end="\(\n\+\[\)\@=" contains=dosiniLabel,dosiniHeader,dosiniComment keepend fold setlocal foldmethod=syntax " Following opens all folds (remove line to start with folds closed). setlocal foldlevel=20