Edit the current quickfix list in a scratch buffer. Write the buffer to push the updates back into the original files and quickfix list.
- Opens the quickfix list in an editable buffer (
[csub],filetype=csub) - Shows file/line/col metadata as virtual text beside each entry
- Applies changes to the underlying files and quickfix list on write
- Run
:Csubto switch back and forth between the quickfix list and the csub buffer - Supports different modes based on quickfix source (text replacement, buffer management)
Example: Find and Replace
- Use as a replacement for
:cfdoand:cdo(Find and replace across multiple files)- Unlike
:cfdoor:cdo, you can make arbitrary changes and see the results before applying them.
- Unlike
- Edit the
Csubbuffer as if you would any other buffer and all changes will be applied when you write the buffer. - Saving(
:w) the Csub buffer will switch back to the updated quickfix list.
Example: Buffer Management
- Configure csub to close buffers when using a buffer picker that populates the quickfix list
- Delete lines in the csub buffer to close the corresponding buffers
- Neovim 0.12 or higher
- Verified with Neovim 0.12.1
vim.pack example (Neovim 0.12+):
vim.pack.add({"https://github.com/anoopkcn/csub.nvim"})
require("csub").setup()Lazy.nvim example:
{
"https://github.com/anoopkcn/csub.nvim",
config = function()
require("csub").setup()
end,
}Packer.nvim example:
use({
"https://github.com/anoopkcn/csub.nvim",
config = function()
require("csub").setup()
end,
})The setup() function accepts an optional table:
require("csub").setup({
-- Handlers to detect mode based on quickfix title
handlers = {
{ match = "FuzzyBuffers", mode = "buffers" },
{ match = "FuzzyFiles", mode = nil }, -- disable csub
{ match = "Grep", mode = "replace" },
{ match = "vimgrep", mode = "replace" },
},
-- Fallback mode when no handler matches (default: "replace")
default_mode = "replace",
})Handlers allow csub to behave differently based on what command created the quickfix list. Each handler has:
match: A string to match against the quickfix list title (plain text match)mode: The mode to use when matched
| Mode | Delete line | Edit text | Use case |
|---|---|---|---|
"replace" |
Remove from QF | Replace line in file | Grep results, compiler errors |
"buffers" |
Close buffer (:bdelete) |
Ignored | Buffer pickers |
nil |
- | - | Disable csub for this QF |
Notes:
- In
"buffers"mode, use:w!to force-close modified buffers - The mode is detected from the quickfix title when
:Csubis invoked
- Populate a quickfix list (e.g.
:make,:grep, diagnostics). - Run
:Csubto open the list in the existing quickfix window for editing. - Edit the lines directly. Deleting a line removes that quickfix entry; adding lines is rejected.
- Run
:Csubagain at any point to toggle back to the quickfix window without discarding unsaved edits. - Write (
:w) to apply changes back to the underlying files and quickfix list; the view jumps back to the quickfix list.
NOTE: closing the csub buffer without writing discards all changes.
Useful keymap:
vim.keymap.set("n", "<leader>s", "<cmd>Csub<cr>", { desc = "Csub the current quickfix" })- Metadata is virtual text; line wrapping is disabled locally.
- If the target line changed since the quickfix list was built and differs from your edit, the plug-in reports an error and leaves that entry untouched.
Run :help csub after installing (requires :helptags doc).