Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lestoni
Last active April 12, 2024 18:15
Show Gist options
  • Star 75 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save lestoni/8c74da455cce3d36eb68 to your computer and use it in GitHub Desktop.
Save lestoni/8c74da455cce3d36eb68 to your computer and use it in GitHub Desktop.
vim folding cheatsheet

via (https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

  • 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.
@ryantuck
Copy link

Great cheat sheet! Discovered one more trick:

  • zc closes current fold

@alarbada
Copy link

Love it, direct to ny bookmarks

@jgillman
Copy link

jgillman commented Jun 2, 2021

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

@frkca
Copy link

frkca commented Oct 17, 2023

So easy so glad to have Google finding this one ;-)

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