Skip to content

PrAsAnNaRePo/inline_edit.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inline_edit.nvim

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.

Requirements

  • Neovim 0.10+ (uses vim.system and vim.diff)
  • The claude CLI installed, on your $PATH, and authenticated (claude auth login)

Security model

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.

Install

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" }.

Usage

  1. Type an instruction where you want the change, e.g.:
    create a function to convert blob to bytes
    
  2. Visually select that line (V then extend as needed).
  3. Press <leader>k (or run :InlineEdit).

Fast mode (default)

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.

Agent mode

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 buffer
  • r / <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.

Configuration

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,
})

How it talks to claude

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 (like cat file | claude -p "query").
  • Agent mode (/agent or /a prefix): claude -p --output-format json --tools "Read,Edit,Grep,Glob" --permission-mode acceptEdits --max-turns 8 "<prompt>", run with cwd set to your Neovim working directory.

Known limitations

  • 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.

About

Neovim plugin to use claude to edit code within nvim.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages