Without navigating to window or tabs, without leaving the keyboard you can edit files in place. Type a plain-English instruction into your buffer, select it, and have the claude CLI turn it into a real code change in place, with a diff to review before it sticks.
- Neovim 0.10+ (uses
vim.systemandvim.diff) - The
claudeCLI installed, on your$PATH, and authenticated (claude auth login)
Read this before installing. Agent mode edits files on disk automatically,
with no per-edit confirmation — it runs claude -p with
--permission-mode acceptEdits because print/headless mode can't answer
interactive permission prompts. The tradeoff is a mandatory diff review
after the fact (accept/reject), not before. Fast mode is the default and
never touches disk. See Agent mode below for exactly what
tool access it gets and how to narrow it.
lazy.nvim:
{
"PrAsAnNaRePo/inline_edit.nvim",
keys = { { "<leader>k", mode = "x" } },
opts = {},
}packer.nvim:
use({
"PrAsAnNaRePo/inline_edit.nvim",
config = function()
require("inline_edit").setup({})
end,
})vim-plug:
Plug 'PrAsAnNaRePo/inline_edit.nvim'
" then, in your init.lua or a lua heredoc:
" require("inline_edit").setup({})opts = {} / setup({}) uses the defaults below. Pass a table to override
any of them — e.g. opts = { keymap = "<leader>k" }.
- Type an instruction where you want the change, e.g.:
create a function to convert blob to bytes - Visually select that line (
Vthen extend as needed). - Press
<leader>k(or run:InlineEdit).
It sends the whole buffer as read-only context via stdin, asks
Claude for a plain text completion with no tool access (--tools ""), and
swaps the returned snippet directly into the buffer. Nothing is written to
disk, you can undo with u like any other edit. Good for generating new,
self-contained code; not for finding/editing code elsewhere in the file.
Edits files on disk automatically — see Security model.
Prefix the selection with /agent (or the shorthand /a) to opt in:
/agent add input validation to the login function
/a add input validation to the login function
The selected text is replaced with a marker comment (e.g.
// INLINE_EDIT: add input validation to the login function), the file is
saved, and claude -p runs headlessly with file-editing tools
(Read,Edit,Grep,Glob by default) to resolve the marker and edit the file
on disk directly. This is the mode to reach for when the instruction needs
to find and modify existing code, since it gives Claude real Read/Edit
access instead of a single text completion.
Because -p mode can't answer interactive permission prompts, this runs
with --permission-mode acceptEdits — edits apply automatically, with no
per-edit confirmation. To compensate, once the run finishes you get a
diff preview in a floating window:
a/<CR>— accept: keep the change (already on disk), sync the bufferr/<Esc>/q— reject: restore the original file content on disk and in the buffer, as if the instruction was never run
Claude may touch other files it judges relevant if your agent_tools /
project layout allow it — the tool list defaults to no Bash and no
Write, keeping it scoped to editing files that already exist, but it is
not hard-sandboxed to a single file. Review the diff before accepting.
require("inline_edit").setup({
keymap = "<leader>k", -- visual-mode keymap; false to disable
agent_flags = { "/agent", "/a" }, -- prefixes that route to agent mode
model = nil, -- e.g. "sonnet"; nil = claude's default
agent_tools = "Read,Edit,Grep,Glob",
agent_permission_mode = "acceptEdits",
max_turns = 8,
marker_prefix = "INLINE_EDIT:",
timeout_ms = 120000,
})Both modes call claude -p --output-format json (see the
CLI reference) via
vim.system, asynchronously:
- Fast mode (default):
claude -p --output-format json --tools "" "<prompt>", buffer piped over stdin (likecat file | claude -p "query"). - Agent mode (
/agentor/aprefix):claude -p --output-format json --tools "Read,Edit,Grep,Glob" --permission-mode acceptEdits --max-turns 8 "<prompt>", run withcwdset to your Neovim working directory.
- Selections are always treated line-wise (whole lines spanned by the visual selection), not partial-line ranges.
- Agent mode requires the buffer to already be an existing file on disk.
- No streaming/progress output — you get a "thinking" notification and then a result notification when the process exits.