Tags: scratch

Creating Custom Scratch Buffers in VIM

The other day I wanted to open a scratch buffer to write some temporary code and the pass it on to a repl to test it out, the idea was that I could modify it as needed and resend it back to the repl and see the changes, helps to debug easily.

So I just wrote out this simple code here that allows me to launch a scratch buffer in different ways, but the difference is I can set various options for it while creating it. First lets have a look at the code :

Now this allows me to open a scratch buffer with various options, like I could call :Sedit ft=javascript and that would open a scratch buffer with filetype javascript (and hence show the right syntax highlighting). The cool part is all these options are set local to the buffer and can just be space separated to the command. The buffer will not be listed in :ls and after you :q it will be wiped out completely from vim. Couldn’t be any simpler!

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)