Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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>
share|improve this answer
    
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! –  Cris Stringfellow Feb 27 '13 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 Feb 27 '13 at 2:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.