Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
vim folding cheatsheet

via (

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
  • zr decreases the foldlevel by one.
  • zR decreases the foldlevel to zero -- all folds will be open.
  • zd deletes the fold at the cursor.
  • zE deletes all folds.
  • [z move to start of open fold.
  • ]z move to end of open fold.
Copy link

mofelee commented May 11, 2017

Awesome !

Copy link

lutzenburg commented Apr 22, 2018

Great cheat sheet. Thanks!

Copy link

ryantuck commented Jul 21, 2020

Great cheat sheet! Discovered one more trick:

  • zc closes current fold

Copy link

not-rusty commented Jan 21, 2021

Love it, direct to ny bookmarks

Copy link

jgillman commented Jun 2, 2021

This list is missing the critical za! It toggles the fold at the cursor open/closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment