Jake Worth

Vim Scratchpad

Published: August 25, 2022 2 min read

  • vim

Today I’d like to share a small part of my practice: using a persisted scratchpad text file for jotting things down.

When coding, often I’ll need to save a piece of data or type something out. This could be the identifier of a record, or a list of steps my pair and I think we need to take to fix a problem.

Instead of creating a new file each time, I keep a scratchpad in my root directory, named ~/buffer. I’ve mapped Vim to open it from normal mode with <leader> g:

" Open my scratchpad
nnoremap <leader>q :e ~/buffer<cr>

You can enter the file in insert mode by adding i<cr> to the end of the mapping.

When I need to jot something down quickly, I hit this command with muscle memory and start typing.

It’s persisted, so my notes last long after my current programming session has ended. And it’s outside of my project directory, so I don’t need to ignore it in version control or worry that it will be accidentally committed or blown away.

✉️ Get better at programming by learning with me. Subscribe to Jake Worth's Newsletter for bi-weekly ideas, creations, and curated resources from across the world of programming. Join me today!


Blog of Jake Worth, software engineer in Maine.

© 2022 Jake Worth.