A floating window "scratchpad" plugin for Neovim, inspired by i3wm. Quickly stash buffers in a floating window with LIFO stack behavior.
scratchpad-demo.mp4
- When working on my laptop - the screen real estate is limited for me to have multiple splits open. Much easier to have a "scratchpad" popup and disappear as needed. Be it note-taking, referencing code, or temporary edits.
- I use one claude code instance inside of my nvim as well that I frequently interact with/guide - having a floating window popup the moment its done processing & sends a notification via the terminal is super useful.
The following plugins come close to what I wanted, so you might as well take a look at these:
- Floating window scratchpad: Move buffers to a floating window for quick access
- LIFO stack behavior: Most recently added buffers appear first
- Cycle through buffers: Navigate between stashed buffers
- Persistent visibility: Hide and show the scratchpad without losing state
- Configurable: Customize size, position, border, and keybindings
- Neovim 0.7+
Plug 'PremBharwani/scratchpad.nvim'use 'PremBharwani/scratchpad.nvim'{
'PremBharwani/scratchpad.nvim',
config = function()
require('scratchpad').setup()
end
}require("scratchpad").setup({
width = 0.8, -- 80% of editor width (or absolute number)
height = 0.8, -- 80% of editor height (or absolute number)
position = "center", -- Window position
border = "rounded", -- Border style
title = true, -- Show title with buffer name and position
mappings = {
toggle_buffer = "<leader>sa",
toggle_visibility = "<leader>ss",
cycle_next = "<leader>sn",
cycle_prev = "<leader>sp",
},
local_mappings = {
close = "q",
cycle_next = "<Tab>",
cycle_prev = "<S-Tab>",
},
})| Command | Description |
|---|---|
:ScratchpadToggle |
Toggle current buffer in scratchpad |
:ScratchpadShow |
Toggle scratchpad visibility |
:ScratchpadNext |
Cycle to next buffer |
:ScratchpadPrev |
Cycle to previous buffer |
:ScratchpadList |
List buffers in scratchpad (debug) |
:ScratchpadHide |
Hide scratchpad window |
| Mapping | Action |
|---|---|
<leader>sa |
Toggle buffer in scratchpad |
<leader>ss |
Toggle scratchpad visibility |
<leader>sn |
Cycle to next buffer |
<leader>sp |
Cycle to previous buffer |
| Mapping | Action |
|---|---|
q |
Hide scratchpad |
<Tab> |
Cycle next |
<S-Tab> |
Cycle previous |
- Open some files in Neovim
- Press
<leader>sato add the current buffer to the scratchpad - The buffer moves to the floating window; your main window shows the alternate buffer
- Add more buffers with
<leader>sa - Cycle through buffers with
<leader>snand<leader>sp - Hide the scratchpad with
<leader>ssorq - Show it again with
<leader>ss- same buffer will be visible - Toggle a buffer again to remove it from the scratchpad
The scratchpad uses LIFO (Last In, First Out) ordering:
- Add buffers A, B, C in order -> stack is
[C, B, A] - C (most recent) is displayed first
- Cycle forward: current goes to bottom ->
[B, A, C], showing B - Cycle backward: bottom comes to current position
local scratchpad = require("scratchpad")
scratchpad.setup(opts) -- Initialize with options
scratchpad.toggleFloatingBuffer() -- Toggle buffer in scratchpad
scratchpad.toggleScratchpadVisibility() -- Show/hide scratchpad
scratchpad.cycleScratchpadBuffers(1) -- Cycle next
scratchpad.cycleScratchpadBuffers(-1) -- Cycle previous
scratchpad.show() -- Show scratchpad
scratchpad.hide() -- Hide scratchpad
scratchpad.list() -- Print buffer listAll yours :)
- Cheers to the chad developers who've handwritten stuff so that claude code could train on them & one-shot this.
- i3wm GOAT window manager for the inspiration!