nvim/Q/How can I quickly collapse and expand a block in nvim?
How can I quickly collapse and expand a block in nvim?
Answer
- AI/Response
- Use nvim's built-in folding commands. The fastest way is
zato toggle a fold open/closed under the cursor. Core fold toggle commands
Fold methods
With tree-sitter (recommended for modern configs)
- If you use nvim-treesitter, enable expression-based folding:
With nvim-ufo (enhanced folding plugin)
- nvim-ufo provides a more polished fold experience with virtual text showing the number of folded lines. It remaps
zR/zMand supports LSP + tree-sitter providers.
- nvim-ufo provides a more polished fold experience with virtual text showing the number of folded lines. It remaps
Quick tip: disable folding on open
Sources
- Use nvim's built-in folding commands. The fastest way is
- AI/Response