3

Pressing spacebar on a + fold in vim in diff mode causes the fold to open.

What and where do I key if I want to close the fold again?

1 Answer 1

5

I believe you want z+c to close the fold. You can read more by typing :help fold in vim. The following is pasted for convenience:

zo Open one fold under the cursor. When a count is given, that many folds deep will be opened. In Visual mode one level of folds is opened for all lines in the selected area.

zc Close one fold under the cursor. When a count is given, that many folds deep are closed. In Visual mode one level of folds is closed for all lines in the selected area. 'foldenable' will be set.

Also, za can be used to toggle the fold open or closed. There is a vim tip on the wiki that describes mapping the key to the spacebar with the following:

nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
2
  • It works. Plus now I can have VStudio style folding! If only Vim had a code intelligence, or whatever that thing in VStudio was called. Plus that remap works nicely too. The guy's a genius! Commented Feb 27, 2013 at 1:32
  • They called it Intellisense. Vim has some built in shortcuts for this in insert mode: ctrl+n and ctrl+x ctrl+n. See: :help i_ctrl-N & :help i_CTRL-X_CTRL-N
    – Brett
    Commented Feb 27, 2013 at 2:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .