Jichao
Jichao

Reputation: 41775

Is there any code-collapse-plugin of vim like this?

alt text When I click the plus sign, the code would automatically collapse.

Is there any plugin like this?

Upvotes: 8

Views: 7893

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798446

Setting foldcolumn to a number greater than 0 will put a + at the beginning of the line that you can click to fold or unfold blocks.

Upvotes: 2

Cascabel
Cascabel

Reputation: 496722

It looks like you're looking for folding. Essentially all you need to get started is:

set foldmethod=syntax
set foldcolumn=<n>     " the number of columns to use for folding display at the left

and to manipulate it with the mouse, set mouse=a to turn on mouse stuff. The + and - to open/close folds appear in the foldcolumn at the left, next to the line numbers, not directly by the code as you've drawn, but it ought to be good enough! You'll probably want a column width of at least a couple, so you can see folds beyond the first level.

This does depend on folding having been defined for the syntax of the filetype you're currently editing. Vim comes with folding rules for some common things like C, but not everything. It's possible that if it's not shipped with vim, someone's created it, and you could find something suiting you out there.

Upvotes: 16

Related Questions