Simple scratch buffers for Neovim
add github mirror
improve error checking
initial commit


browse  log 



You can also use your local clone with git send-email.

#Neovim Scratch Buffer Plugin

This plugin provides a simple way to work with scratch buffers in Neovim. It allows you to quickly open a scratch buffer in your current window or in a new split window. The plugin also offers the flexibility to configure the default name of the scratch buffer.

This plugin is based on vim-scratch, but written in lua for Neovim.


  • Open a scratch buffer in the current window.
  • Open a scratch buffer in a new split window.
  • Automatically switch to an existing scratch buffer if it's already open.
  • Configure the default name for the scratch buffer.
  • The scratch buffer acts as a temporary workspace and is not backed by a file.


To install this plugin, you can use your favorite Neovim package manager. For example:

  lazy = true,
  keys = {
    { "<leader>bs", "<cmd>Scratch<cr>", desc = "Scratch Buffer", mode = "n" },
    { "<leader>bS", "<cmd>ScratchSplit<cr>", desc = "Scratch Buffer (split)", mode = "n" },
  cmd = {
  opts = {},


  config = function()


Plug 'https://git.sr.ht/~swaits/scratch.nvim'
lua require("scratch").setup()


The default configuration options are listed below:

opts = {
  -- The name of the scratch buffer
  buffer_name = "_SCRATCH_",



The plugin provides two commands:

  • :Scratch — Opens or switches to the scratch buffer in the current window.
  • :ScratchSplit — Opens or switches to the scratch buffer in a new split window.

#Lua Functions

You can also use the plugin's Lua functions directly:

  • require('scratch').open() — Equivalent to :Scratch.
  • require('scratch').split() — Equivalent to :ScratchSplit.


MIT License


Contributions are welcome! Feel free to open issues or submit pull requests.