0

I am trying to use fold feature of vim. I could fold the text in vim ( used commands zc/zo/zM).

After saving the file with folds, when I re-open, file is shown without any folds. I want to see a file with folds.

I even installed foldplugin for vim. But this problem persists.

How to get a file with folds in vim, when I re-open the file? Pls advise.

Thank you,

Chandra
  • 526
  • 2
  • 9
  • 26
  • Seems like you have some options not set the way you wish. Please report the result of this command: `:set fen? fdl? fdls?` (I suspect `nofoldenable`...) Also, which `foldmethod` is your file using? – Amadan Sep 05 '14 at 02:13
  • :set fen? - foldenable :set fdl? - foldlevel=0 :set fdls? - foldlevelstart=1 and my foldmethod is indent – Chandra Sep 05 '14 at 06:10
  • 1
    See http://stackoverflow.com/q/2142402/546861 – romainl Sep 05 '14 at 06:54
  • hi rominl, I tried the solution given there i.e. Adding this to the top of vimrc let &viewdir=expand("$HOME") . "/.bk/.vim/viewdir" if !isdirectory(expand(&viewdir))|call mkdir(expand(&viewdir), "p", 451)|endif and adding below autocmd BufWrite * mkview autocmd BufNewFile,BufRead * silent loadview – Chandra Sep 05 '14 at 19:09

1 Answers1

1
  1. turn on the folding in .vimirc

    set foldenable

  2. set foldmethod

    use the marker method, add the following line in .vimrc

    set foldmethod=marker

  3. vim support indent, marker, manual, syntax, expr foldmethod

see below links for more details:

http://vim.wikia.com/wiki/Folding

http://vimdoc.sourceforge.net/htmldoc/fold.html

henices
  • 249
  • 1
  • 7
  • I got solution from Drew Neil. Link is here http://stackoverflow.com/a/3660640/128850. Vim does not save folds. So, you need to save session and restore to view the folds. – Chandra Sep 09 '14 at 22:25