Confusion about vim folding - how to disable?

后端 未结 9 1291
暗喜
暗喜 2020-12-22 20:20
  1. When I open the file it looks like this: \"enter or even this
相关标签:
9条回答
  • 2020-12-22 20:57

    Add set nofoldenable to your ~/.vimrc to disable folding.

    0 讨论(0)
  • 2020-12-22 20:58

    The easiest way to disable (and enable) folding on the fly is zi.

    zi is the normal mode command that toggles 'foldenable', just like :set foldenable!.

    Mnemonic: "fold invert". See :h zi.

    0 讨论(0)
  • 2020-12-22 20:59

    You're not alone.

    set nofoldenable    " disable folding
    
    0 讨论(0)
  • 2020-12-22 21:05

    I have added this line to my .vimrc file cause I had the same issue:

    autocmd FileType * exe "normal zR"

    This command will be executed every time you open a file automatically. So you won't see the bug and the folding feature won't be lost too)

    0 讨论(0)
  • 2020-12-22 21:09

    Here is an article which briefly and concisely sums up why folding is cool. The one line reason is that folding makes navigating very large files a breeze.

    If you want to leave folding enabled, and simply always start with all folds open, the vim wiki tells how. The method of interest to you would probably be the autocommand method.

    " Tweak the event and filetypes matched to your liking. 
    " Note, perl automatically sets foldmethod in the syntax file
    autocmd Syntax c,cpp,vim,xml,html,xhtml setlocal foldmethod=syntax
    autocmd Syntax c,cpp,vim,xml,html,xhtml,perl normal zR
    

    I would also recommend searching for custom folding methods for the language you use. Simply googling "vim <insert language here> folding" should bring up a number of options. Play around with the different options until you find a folding method you like.

    0 讨论(0)
  • 2020-12-22 21:09

    Sorry, if I'm answering related question, but I found useful to display two files alongside with folding turned off with something like this:

    vim "+set nofen" -O file1 file2
    
    0 讨论(0)
提交回复
热议问题