xolox / vim-notes

Easy note taking in Vim
http://peterodding.com/code/vim/notes/
1.6k stars 110 forks source link

Error when trying to fold headers.. #74

Closed mellery451 closed 10 years ago

mellery451 commented 10 years ago

I apologize in advance - this might just be user error.

Once I have a header section, I would like to selectively fold it (collapse). I tried zf in normal mode, but I get the error:

E350: Cannot create fold with current 'foldmethod'

Is there some other method for folding header sections? Or perhaps some other plugin is causing me problems...

Thanks for this plugin!

xolox commented 10 years ago

From the Vim documentation (also available online):

                            *zf* *E350*
zf{motion}  or
{Visual}zf  Operator to create a fold.
        This only works when 'foldmethod' is "manual" or "marker".
        The new fold will be closed for the "manual" method.
        'foldenable' will be set.
        Also see |fold-create-marker|.

So it looks like zf only works if foldmethod is set to "manual", while the vim-notes plug-in defines a custom fold method expression (driven by Vim script). I guess you have two choices:

  1. You disable the automatic folding support and define folds manually.
  2. You embrace the automatic folding support and give up manual fold definition.

Does this answer your question?

mellery451 commented 10 years ago

ok - so perhaps I don't know understand how to use the automatic fold support. I see that a header section will automatically expand when I enter it (move right). How do I get it to collapse?

xolox commented 10 years ago

That depends a lot on how you like to use Vim and its text folding feature (it's quite flexible and configurable) ... :-)

Below is what works for me, you may or may not like it but either way it should point you in the right direction:

" Make Vim open and close folded text as needed because I can't be bothered to
" do so myself and wouldn't use text folding at all if it wasn't automatic.
set foldmethod=marker foldopen=all,insert foldclose=all
xolox commented 10 years ago

I just realized, maybe all you're looking for is the zc mapping instead of zf?

mellery451 commented 10 years ago

zc works! .. I guess that's what I needed, but I will also take a look at your automatic fold settings. Thanks again.