Vim Tips Wiki
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 20: Line 20:
 
To [[Use folds in your program|use these folds]], put <code>setlocal foldmethod=syntax</code> in <code>after/ftplugin/vim.vim</code>. While you're at it, it also makes sense to avoid folding in the command window (<code>q:</code>). You can use the following fragment for that:
 
To [[Use folds in your program|use these folds]], put <code>setlocal foldmethod=syntax</code> in <code>after/ftplugin/vim.vim</code>. While you're at it, it also makes sense to avoid folding in the command window (<code>q:</code>). You can use the following fragment for that:
   
  +
<pre>
βˆ’
<source lang='vim'>
 
 
" Folding via syntax is used for this filetype.
 
" Folding via syntax is used for this filetype.
 
setlocal foldmethod=syntax
 
setlocal foldmethod=syntax
Line 36: Line 36:
 
setlocal foldcolumn=4
 
setlocal foldcolumn=4
 
endif
 
endif
βˆ’
</source>
+
</pre>
   
 
Alternatively, you can use an autocommand or a mapping to enable folding. If using an autocommand, the FileType and Syntax events are probably the best ones to use. Calling <code>zR</code> as well when you do this will [[All folds open when opening a file|start with all the folds open when loading the file]].
 
Alternatively, you can use an autocommand or a mapping to enable folding. If using an autocommand, the FileType and Syntax events are probably the best ones to use. Calling <code>zR</code> as well when you do this will [[All folds open when opening a file|start with all the folds open when loading the file]].
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)