https://github.com/aiya000/vim-scratch-buffer
🚀 No more hassle with file paths! Instantly open a scratch buffer!
https://github.com/aiya000/vim-scratch-buffer
cline quickrun roo roocode vim vim-plugin
Last synced: about 1 year ago
JSON representation
🚀 No more hassle with file paths! Instantly open a scratch buffer!
- Host: GitHub
- URL: https://github.com/aiya000/vim-scratch-buffer
- Owner: aiya000
- License: mit
- Created: 2025-02-24T15:00:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-20T17:43:44.000Z (about 1 year ago)
- Last Synced: 2025-04-10T09:03:41.889Z (about 1 year ago)
- Topics: cline, quickrun, roo, roocode, vim, vim-plugin
- Language: Vim Script
- Homepage:
- Size: 73.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# :sparkles: scratch-buffer.vim :sparkles:
:rocket: **No more hassle with file paths!** The fastest way to open an instant scratch buffer.
For Vim/Neovim.
- - -

- - -
This Vim plugin is created by **Cline (Roo Code)** and me!
- - -
## Table of Contents
- [:sparkles: scratch-buffer.vim :sparkles:](#sparkles-scratch-buffervim-sparkles)
- [:wrench: Quick Start](#wrench-quick-start)
- [:fire: Why scratch-buffer.vim?](#fire-why-scratch-buffervim)
- [:zap: Supercharge with vim-quickrun!](#zap-supercharge-with-vim-quickrun)
- [:balance_scale: Comparison with scratch.vim](#balance_scale-comparison-with-scratchvim)
- [:gear: Detailed Usage](#gear-detailed-usage)
- [:keyboard: Default Keymappings](#keyboard-default-keymappings)
- [:sparkles: scratch.vim Compatibility](#sparkles-scratchvim-compatibility)
## :wrench: Quick Start
```vim
:ScratchBufferOpen " Open a temporary buffer using default options
:ScratchBufferOpen md sp 5 " Open a temporary Markdown buffer with :sp and height 5
:ScratchBufferOpenFile ts vsp 100 " Open a persistent TypeScript buffer with :vsp and width 100
:ScratchBufferOpenNext " Open next temporary buffer
:ScratchBufferOpenFileNext " Open next persistent buffer
```
Please see '[Detailed Usage](#gear-detailed-usage)' section for more information.
## :fire: Why scratch-buffer.vim?
- **Open instantly!** Just run `:ScratchBufferOpen`!
- **No file management!** Perfect for quick notes and testing code snippets.
- **Works anywhere!** Whether in terminal Vim or GUI, it's always at your fingertips.
## :zap: Supercharge with vim-quickrun!
:bulb: **Combine it with [vim-quickrun](https://github.com/thinca/vim-quickrun) to execute code instantly!**
```vim
" Write TypeScript code...
:ScratchBufferOpen ts
" ...and run it immediately!
:QuickRun
```
## :balance_scale: Comparison with scratch.vim
[scratch.vim](https://github.com/mtth/scratch.vim) is a great plugin.
However, vim-scratch-buffer adds more features.
Compared to scratch.vim, vim-scratch-buffer provides these additional features:
- Flexible buffer management
- Open multiple buffers with sequential numbering (`:ScratchBufferOpenNext`)
- Quick access to recently used buffers (`:ScratchBufferOpen`)
- When you want to take notes on different topics, scratch.vim only allows one buffer
- See `:help :ScratchBufferOpen` and `:help :ScratchBufferOpenNext`
- Buffer type options
- Choose between writeable buffers or temporary buffers
- Automatic saving for file buffers when enabled
- Convert temporary buffers to persistent ones when needed
- See `:help :ScratchBufferOpen` and `:help :ScratchBufferOpenFile`
- Customization options
- Specify filetype for syntax highlighting
- Choose opening method (`:split` or `:vsplit`)
- Control buffer height/width
- Configurable auto-hiding behavior
### :gear: Detailed Usage
```vim
" Basic Usage
" Open a temporary buffer using default settings
:ScratchBufferOpen
" Same as :ScratchBufferOpen but opens a writable persistent buffer
:ScratchBufferOpenFile
```
```vim
" Open a new scratch buffer with a specific filetype
" Example: Markdown
:ScratchBufferOpen md
" Example: TypeScript
:ScratchBufferOpen ts
" Example: No filetype
:ScratchBufferOpen --no-file-ext
```
```vim
" Open multiple scratch buffers
:ScratchBufferOpen md " Opens most recently used buffer
:ScratchBufferOpenNext md " Always creates a new buffer
```
```vim
" Open a small buffer at the top for quick notes
:ScratchBufferOpen md sp 5
:ScratchBufferOpen --no-file-ext sp 5
```
```vim
" Delete all scratch files and buffers
:ScratchBufferClean
```
## :keyboard: Default Keymappings
When `g:scratch_buffer_use_default_keymappings` is enabled (default: `v:false`), the following keymappings are available:
```vim
" Quick open commands (execute immediately)
nnoremap b ScratchBufferOpen
nnoremap B ScratchBufferOpenFile
" Interactive commands (allows adding arguments)
nnoremap b :ScratchBufferOpen
nnoremap B :ScratchBufferOpenFile
```
The quick open commands create buffers with default settings, while the interactive commands let you specify file extension, open method, and buffer size.
You can customize these mappings by disabling the defaults:
```vim
let g:scratch_buffer_use_default_keymappings = v:false
```
And then defining your own:
```vim
" Example custom mappings
nnoremap s ScratchBufferOpen
nnoremap S ScratchBufferOpenFile
```
## :sparkles: scratch.vim Compatibility
To make the plugin behave like scratch.vim, you can enable automatic buffer hiding!
When enabled, scratch buffers will automatically hide when you leave the window.
You can configure this behavior separately for temporary buffers and file buffers.
Enable both types of buffer hiding with:
```vim
let g:scratch_buffer_auto_hide_buffer = #{
\ when_tmp_buffer: v:true,
\ when_file_buffer: v:true,
\ }
```
Or enable hiding for only temporary buffers:
```vim
let g:scratch_buffer_auto_hide_buffer = #{ when_tmp_buffer: v:true }
```
Or enable hiding for only file buffers:
```vim
let g:scratch_buffer_auto_hide_buffer = #{ when_file_buffer: v:true }
```