How do I open a scratch split that is not listed and disappears when I close it?
Answer
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
Explanation
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap artifacts. A disposable scratch split gives you an isolated workspace that behaves like a temporary pad and cleans itself up when you close it.
How it works
:vnewopens a new vertical split with an empty buffersetlocal buftype=nofilemarks the buffer as not associated with a filebufhidden=wiperemoves the buffer completely when it is abandonednobuflistedkeeps it out of the normal buffer listnoswapfileprevents swapfile creation for this temporary content
The result is ideal for short-lived tasks: collecting snippets during refactors, staging text before a substitution, or comparing fragments without polluting your normal buffer workflow.
Example
Before: two code windows, no temporary workspace.
After running the command: a new right-side split appears for scratch text.
Close that split, and the scratch buffer is wiped immediately.
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
Tips
- Add
nowrapandnonumberif you want a cleaner note-taking pane - Map this command to a key if you use scratch buffers frequently
- If you want the scratch buffer to survive window closes, use
bufhidden=hideinstead ofwipe