vim folding

A concise article on Linux.com (that I keep referring back to) about vim folding. I’ve been using vi/vim for years and vi keystrokes just “happen”, but it’s always nice to learn a few more tricks, especially when working with larger scripts.

A brief summary of folding:

  • highlight some text using v visual mode, zf to fold, zo to unfold (ie open)
  • put cursor on an opening curly bracket, and  zfa} to fold until closing curly bracket (or zfa) or zfa] for parentheses, square brackets)
  • add this to your .vimrc to remember folds:
au BufWinLeave * mkview
au BufWinEnter * silent loadview

Lots more commands in the article.

Tags:


Share This


 


2 Responses to vim folding

  1. Thanks! (; Used commands to remember folds (;

  2. Thanks a lot for the remember folds tip.
    I have been struggling with this for a while, really annoying, although it only happens for cpp files, not for python or vim scripts.
    But yout tip solved the problem.
    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>