9

With vimwiki you can fold headers and lists as following:

Example for headers and list folding:

= My current task =
  * [ ] Do stuff 1
    * [ ] Do substuff 1.1
    * [ ] Do substuff 1.2
      * [ ] Do substuff 1.2.1
      * [ ] Do substuff 1.2.2
    * [ ] Do substuff 1.3
  * [ ] Do stuff 2
  * [ ] Do stuff 3

Hit zM:

= My current task = [8] --------------------------------------

Hit zr:

= My current task =
  * [ ] Do stuff 1 [5] --------------------------------------
  * [ ] Do stuff 2
  * [ ] Do stuff 3

Hit zr one more time:

= My current task =
  * [ ] Do stuff 1
    * [ ] Do substuff 1.1
    * [ ] Do substuff 1.2 [2] -------------------------------
  * [ ] Do substuff 1.3
  * [ ] Do stuff 2
  * [ ] Do stuff 3

The header-folding (= Header =) does works for me, but list-folding (* [ ] list) doesn't.

Vimwiki says this about list-folding, but I don't understand what it exaclty means:

NOTE: If you use the default vimwiki syntax, folding on list items will work properly only if all of them are indented using current shiftwidth. For MediaWiki, * or # should be in the first column.

My vimrc is as following:

call vundle#begin()
Plugin 'vimwiki'
call vundle#end()

set nocompatible
filetype plugin on
syntax on
set foldmethod=syntax
4
  • Is that your entire vimrc file? Plugin 'vimwiki' looks like Vundle, but AFAIK you need to use call vundle#begin() and call vundle#end()... Commented Mar 4, 2015 at 22:01
  • @Carpetsmoker No, it's not my entire vimrc :-). I've published only the settings that are related to vimwiki. Yes, I'm using Vundle to manage my plugins. Thanks for editing my question b.t.w. :-).
    – user1214
    Commented Mar 4, 2015 at 22:06
  • Okay :-) If you post a small snippet from a vimrc, you should probably test it, just to make sure that a) you can still reproduce the problem with it, and b) there are no errors in it :-) You can use vim -u test-vimrc.vim to use a different vimrc file. Commented Mar 5, 2015 at 13:15
  • I have the same problem, and it appears to be a bug. I've posted here a request to help to solve the bug.
    – Mr.Eee
    Commented Mar 7, 2015 at 1:44

1 Answer 1

10

Folding lists in VimWiki

According to the documentation in vimwiki version 2.1 (the latest I found), there are a few fold methods, and of them only one works for folding list items.

The setting is in the variable g:vimwiki_folding. from :help g:vimwiki_folding:

Enable/disable vimwiki's folding (outline) functionality. Folding in vimwiki can uses either the 'expr' or the 'syntax' foldmethod of Vim.

Value           Description  
''              Disable folding.  
'expr'          Folding based on expression (folds sections and code blocks).  
'syntax'        Folding based on syntax (folds sections; slower than 'expr').  
'list'          Folding based on expression (folds list subitems; much slower).

Default: ''

Since your vimrc is setting foldmethod=syntax explicitly, and you don't mention setting g:vimwiki_folding, my guess is that you are getting the syntax setting, which only supports sections.

Add

let g:vimwiki_folding='list'

to your vimrc and it should work.

You can also run that command and then reopen the file (e.g. with ':e') and observe the folding work.

Shift Width

You also asked about shift width indentation. In Vim, the shiftwidth is used in auto-indentation and shift commands (e.g. >>). The default is 8 and is equal to the tabstop. If you don't mess with those settings, you'll be fine with your indented lists.

If you do change them but don't have them equal, you'll still be okay as long as your list is indented with either >> and <<, or the VimWiki specific glm and gll commands, which both use the shiftwidth setting and thus would be compatible with the folding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.