Skip to content

Add ScratchToggle Command #41

@alichtman

Description

@alichtman

I wanted to set up a scratch buffer that is toggle-able (like :ScratchPreview) and automatically focuses my cursor on the buffer when opening it. I was expecting a :ScratchToggle command, but did not find one.

Here's my current config for scratch in lazy.nvim:

return {
  "mtth/scratch.vim",

  keys = {
    { "<leader>sp", ":ScratchPreview<CR>", mode = "n", noremap = true, silent = true },
    { "<leader>sp", ":ScratchSelection<CR>", mode = "v", noremap = true, silent = true },
  },

  init = function()
    vim.g.scratch_no_mappings = 1
    vim.g.scratch_persistence_file = "~/scratchpad/vim-scratchpad.txt"
    vim.g.scratch_autohide = 0
  end,
}

When I want to open a scratch window, I use <leader>sp. This opens a scratch buffer, but I have to manually move the cursor there.

Any chance this could be added to the plugin?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions