vimtricks.wiki Concise Vim tricks, one at a time.

How do I keep more marks and registers across sessions by tuning the shada option?

Answer

:set shada='200,<1000,s100,h

Explanation

Default ShaDa settings are conservative, which can make long-running workflows lose useful context between sessions. By tuning 'shada', you can retain more command/search history and larger register contents while still bounding disk usage. This is valuable if you depend on cross-session marks, macro snippets, and search recall in large projects.

How it works

  • '200 stores up to 200 items from command/history data.
  • <1000 keeps up to 1000 lines of register contents.
  • s100 limits item size to 100 KB per register payload.
  • h disables storing hlsearch state across sessions (optional but often cleaner).

Applied together:

:set shada='200,<1000,s100,h

This expands persistence without turning ShaDa into an unbounded dump.

Example

Before tuning, you might close Vim and lose older recorded edits or long yank payloads sooner than expected. After setting a larger < value, reopening Vim gives you much better register continuity for recurring refactor routines.

Before: older register content drops quickly
After:  register history survives larger multi-file sessions

Tips

  • Put the setting in your init file for permanence.
  • Inspect current value with :set shada?.
  • If startup feels slower, reduce ' and < gradually until you hit a good balance.

Next

How do I save only real file buffers when running bufdo across many open buffers?