Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm quite new to VIM, but have been trying to teach myself over the past week, yet I'm encountering a problem which has proven to be quite frustrating:

Currently I'm mostly using VIM to take notes, and use the folding capabilty of VIM to make my work less cluttered. Yet I've encountered a problem, where every bullet point, which goes beyond my set linebreak, folds in itself. To be more clear:

VIM I enter image description here

I would like to not have single bullet points fold.

I seem to have traced the problem to the way my text is indented: since folding seems to happen on an indent-level by default, my bullet points fold due to the second line being 'indented' more. So I gather there are probably to vague ways of solving this issue: telling VIM to fold if the indent on the next line is greater 1, or handle the way bullet points are wrapped completely differently.

How can these solutions be implemented?


I use a plugin called Workflowish, so here is my vimrc:

set tw=100
set formatoptions=tcq
set com=fb:*
set spell
set spelllang=de
colorscheme synic
set fileencoding=utf8
execute pathogen#infect()
syntax on
filetype plugin indent on

And here is what the plugin itsself sets:

setlocal foldlevel=1
setlocal foldenable
setlocal sw=2 sts=2
setlocal expandtab
setlocal foldtext=WorkflowishFoldText()
setlocal foldmethod=expr
setlocal foldexpr=WorkflowishCompactFoldLevel(v:lnum)
setlocal autoindent
share|improve this question
    
That sounds like an issue that you should submit to the plugin's author, not here. –  Ingo Karkat Dec 14 '13 at 17:06
    
I already have, yet even if I try doing it without the plugin, the same issue persits, hence I believe it is plugin-independent. –  montauk Dec 14 '13 at 17:19
add comment

1 Answer

up vote 3 down vote accepted

Unfortunately, there's no way to do this without support from the plugin. (Sort of.)

The key lines here are:

setlocal foldmethod=expr
setlocal foldexpr=WorkflowishCompactFoldLevel(v:lnum)

The first means "use the value of 'foldexpr' to determine the fold level of each line". The second sets that option to use the value of a function defined in the plugin.

Folding in Vim is based on fold levels. In foldmethod=expr, each line is assigned a fold level (an integer) by the 'foldexpr'. Those levels determine where the folds begin and end.


Solution 1: Write a new 'foldexpr'.

This can call WorkflowishCompactFoldLevel(), but adjust the value so that multi-line bullet-items aren't folded. I'll leave this as an exercise, though, because I think it's the wrong approach. Which brings us to:


Solution 2: Make the way it works now not be a problem.

I think the real problem is not that these folds exist, but that they're getting in your way. Can you describe what you do that causes you to even notice that these folds are there? It may be a matter of setting your starting 'foldlevel' appropriately for ft=workflowish buffers.

Ideally, you wouldn't notice that these folds existed until you actually tried to close one.

share|improve this answer
    
Thanks a lot for your detailed answer! Especially your second solution was very helpful. I'm not quite sure if this is too 'hackish' a way to solve my problem, but I've just added the following lines to my .vimrc: autocmd BufWinLeave *.* mkview and autocmd BufWinEnter *.* silent loadview. It seems to be working now! –  montauk Dec 14 '13 at 20:41
    
Huh, I've never used views before. Neat! –  Peeja Dec 15 '13 at 3:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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