How do I keep :mkview files focused on folds and cursor position without restoring unrelated local options?
:set viewoptions=folds,cursor,slash,unix
mkview and loadview are great for restoring editing context, but the default viewoptions can bring back more state than you actually want.
category:
config
tags:
#config
#views
#folding
#sessions
#workflow
How do I make the fold column appear only when needed and cap its width?
If you use folds heavily, a fixed fold column is a tradeoff: foldcolumn=0 hides useful fold cues, while a constant width wastes horizontal space in files that b
category:
config
tags:
#config
#folding
#ui
#windows
How do I jump back in the jumplist and automatically reveal and center the destination?
Jumping backward with is fast, but in folded or dense files it can land you in a collapsed section or near the edge of the screen, forcing extra cleanup keystro
category:
navigation
tags:
#navigation
#jumplist
#folding
#normal-mode
How do I jump to the previous change and reveal it clearly in Vim?
Jumping through the changelist with g; is useful, but in real files the destination can land inside a closed fold or off-center on screen, which slows review.
category:
navigation
tags:
#navigation
#changelist
#folding
#motions
How do I stop :mkview from restoring local options when loading a view?
:set viewoptions-=options
When you use :mkview and :loadview, Vim stores more than folds and cursor position.
category:
config
tags:
#config
#views
#folding
#session-management
#windows
How do I keep each search match centered and unfolded as I jump with n?
When you are stepping through many matches, plain n often lands with poor context and can hide the match inside a closed fold.
category:
navigation
tags:
#navigation
#search
#folding
#normal-mode
How do I control what state gets saved when I use :mkview to snapshot a window?
:set viewoptions=cursor,folds,slash,unix
The viewoptions setting is a comma-separated list that determines exactly what :mkview (and the auto-save view pattern) stores in a view file.
category:
config
tags:
#config
#folding
#views
#options
#ex-commands
How do I use LSP to create accurate code folds based on the language server's understanding of the document structure?
Neovim 0.
category:
config
tags:
#lsp
#folding
#neovim
#config
How do I use Treesitter-aware code folding in Neovim for accurate fold regions based on syntax?
vim.treesitter.foldexpr()
Neovim's built-in Treesitter integration includes vim.
category:
config
tags:
#treesitter
#folding
#config
#neovim
How do I save multiple different views of the same file with independent fold and cursor states?
:mkview 2 and :loadview 2
Vim supports up to 9 numbered view slots per file.
category:
buffers-windows
tags:
#folding
#buffers-windows
#navigation
#config
How do I open folds one level at a time in Vim without revealing all nested folds at once?
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I save and automatically restore a buffer's fold state and cursor position across Vim sessions?
:mkview saves a snapshot of the current window — its fold states, cursor position, and local option values — to a view file on disk.
category:
buffers-windows
tags:
#folding
#buffers-windows
#config
#ex-commands
How do I close all folds and then open just the one containing the cursor to focus on it?
The zMzv sequence collapses every fold in the file and then re-opens only the one containing your cursor.
category:
editing
tags:
#folding
#navigation
#normal-mode
How do I control how many fold levels are open when first opening a file?
When Vim opens a file with folds enabled, it uses the foldlevelstart option to decide how many fold levels to open automatically.
category:
config
tags:
#folding
#config
#navigation
How do I toggle a fold and all its nested folds open or closed at once?
The zA command toggles the fold under the cursor together with all nested sub-folds in one keystroke.
category:
editing
tags:
#folding
#editing
#normal-mode
How do I define custom fold boundaries using a Vimscript expression in Vim?
Setting foldmethod=expr tells Vim to call the foldexpr expression for every line to compute its fold level.
category:
config
tags:
#folding
#config
#normal-mode
How do I customize the text displayed for closed folds in Vim?
The foldtext option controls what Vim displays for a closed fold.
category:
config
tags:
#folding
#config
#normal-mode
How do I open just enough folds to see the current line without expanding everything?
zv (view cursor) opens the minimum number of folds needed to make the current line visible — nothing more.
category:
editing
tags:
#folding
#navigation
#editing
How do I control which actions automatically open folds in Vim?
The foldopen option lets you specify exactly which cursor movements and commands will automatically open a closed fold.
category:
config
tags:
#folding
#config
#ex-commands
How do I show a visual fold depth indicator in the Vim gutter?
Setting foldcolumn to a non-zero value adds a narrow column on the left side of each window that visually represents the fold structure of your file.
category:
config
tags:
#folding
#config
#navigation