vim Folding Folding C blocks


Example

This is our buffer:

void write_buffer(size_t size, char ** buffer)
{
    char * buf = *buffer;
    size_t iter;
    for(iter = 0; iter < size; iter++)
    {
        putc(*(buf + iter));
    }
}

The cursor is at [1][1] ([line][col]). Move the cursor to the curl bracket of the for loop:
/for<Enter>j cursor is [6][2].

Now enter zf% (create folding, move to matching bracket). You have successfully create the first folding.

Now enter :2<Enter>_, the cursor is now at [2][1] and zf%: the complete function body is folded.

You are able to open all foldings you just created using zO and re-close them using zC.