
- Vim Tutorial
- Vim - Home
- Vim - Introduction
- Vim - Installation & Configuration
- Vim - It’s friends
- Vim - Getting familiar
- Vim - Getting help
- Vim - Editing
- Vim - Navigating
- Vim - Revisiting Editing
- Vim - Searching
- Vim - Working With Multiple Things
- Vim - Markers
- Vim - Macros
- Vim - Registers
- Vim - Folding
- Vim - Diff
- Vim - Plug-ins
- Vim - Using Vim as IDE
- Vim - Remote File Editing
- Vim - Tips & Tricks
- Vim - Personalization
- Vim - Conclusion
- Vim Useful Resources
- Vim - Quick Guide
- Vim - Useful Resources
- Vim - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Vim - Folding
Fold functionality will be useful when file contents large text. Using this feature we can only show selected potion of file. This feature is particularly useful while working with programming languages. In this chapter, we will discuss following items −
- Activate and deactivate fold functionality
- Various fold actions
Fold activation and deactivation
To activate fold use following command −
:set foldenable :set foldmethod = indent
To deactivate fold use following command
:set nofoldenable
Fold actions
Close fold
To fold code, go to any method and execute following command −
zc
For example below image shows the result of this action −

Open fold
To open fold use following command −
zo
Below image shows the result of this action −

Close all folds
To close all folds execute following command
zM
Below image shows the result of this action

Unfold all
To unfold all execute following −
zR
Below image shows the result of this action −

Advertisements