Skip to content

Using the Inline Interaction ​

As per the Getting Started guide, the inline interaction lets the LLM edit the current buffer directly. Run :CodeCompanion <your prompt> to let it edit the whole buffer, or make a visual selection first to limit its edits to those lines. Running :CodeCompanion on its own opens an input box to write your prompt in, with the adapter and model that will answer in its title.

You can also call inline prompts from the prompt library by their alias, such as :'<,'>CodeCompanion /docstrings.

How Edits Work ​

The current buffer is shared with the LLM, which edits it by calling the edit_file tool, once per change. What it can edit depends on your selection:

  • No selection - The LLM can edit anything it's been shared
  • Visual selection - The LLM can only edit the selected lines. The rest of the buffer is still shared, so it can see imports and surrounding code

If a buffer is over the context limit, only the lines around your cursor, or your selection, are shared. Without a selection, those are also the only lines the LLM can edit.

If an edit fails, for example because the text it targets isn't in the buffer, the error is sent back to the LLM once so it can try again. If it fails a second time, nothing is changed and the error is logged.

If you ask a question rather than for a change, such as "what does this function do?", the LLM replies without editing and the reply opens in a float. The cursor moves into the float so you can scroll a long reply, and q closes it.

By default, the LLM's edits are shown as a diff in the buffer, which you can review a hunk at a time. Press ? in the diff to see these keymaps:

KeymapAction
} / {Move to the next or previous hunk
gaAccept the hunk under the cursor
grReject the hunk under the cursor
uUndo your own edits to the buffer, then the last hunk you accepted or rejected
g2Accept the hunks that are left
g3Reject the hunks that are left
g1Accept the hunks that are left, and every future edit to this buffer

Editing the buffer during a review pauses hunk actions, as they would overwrite your edits. Press u to undo your edits and carry on, or g2 to keep them along with the hunks that are left.

Once every hunk has been accepted or rejected, the diff closes. Pressing u afterwards undoes the whole edit in one step, however many hunks you resolved, and rejecting every hunk leaves nothing to undo. The diff can be turned off with display.diff.enabled, the banner above the current hunk hidden with display.diff.show_banner, and the keymaps changed in interactions.shared.keymaps.

Input Box ​

The input box has its own keymaps:

KeymapAction
<CR> or <C-s>Send the prompt
q or <Esc>Close the input box, keeping what you've written
<Up> or <Down>Continue the last conversation, or step through earlier prompts
gaChange the adapter and model

While the LLM is working, press q in the buffer to stop the request.

Adapters ​

The inline interaction works with HTTP adapters and ACP agents such as Claude Code and Codex. An HTTP adapter's model must support tool calling, as that's how the LLM edits the buffer.

Press ga in the input box to pick an adapter and model. Your choice is remembered for that buffer, so later inline prompts in it use the same adapter and model until you pick again. Other buffers keep using interactions.inline.adapter.

For a one-off, include the adapter in your prompt with adapter=*. For example :<','>CodeCompanion adapter=deepseek can you refactor this?. This isn't remembered, and can be combined with editor context.

ACP Agents

An agent edits a temporary copy of the buffer rather than the buffer itself, and its edits are brought back for you to review. It can read and search your project, but it can't edit any other file or run commands. Each agent works on one inline prompt at a time, and your rules and skills aren't sent to it, as it loads its own.

Continuing a Conversation ​

Each buffer remembers its last inline conversation, so you can follow up on a reply or ask for another change without starting again. Press <Up> in the input box to continue it, and the title changes to Continue with the conversation's adapter and model. Press <Up> again to step back through the prompts you sent, and <Down> to step forward and then out to a new conversation.

A fresh copy of the buffer goes with each prompt, so the LLM sees any edits you've accepted, rejected or made yourself since. A continued conversation keeps its adapter and model, so ga only works once you've pressed <Down> to start a new one. With an ACP agent, the agent's session carries on, unless the agent has restarted.

Sending a prompt without continuing replaces the buffer's conversation with a new one. Without a conversation to continue, <Up> and <Down> step through the last 20 prompts you've sent.

Editor Context ​

The inline interaction allows you to send context alongside your prompt via the notion of editor context. That is, context that relates to your current Neovim session:

  • chat - shares the LLM's messages from the last chat buffer
  • clipboard - shares the data on your clipboard with the LLM

Include them in your prompt, for example :CodeCompanion #{clipboard} use this function in the buffer. Multiple context items can be sent as part of the same prompt, and you can add your own as per the configuration.

Limitations ​

  • A selection is limited by whole lines, so selecting part of a line lets the LLM edit all of it.
  • If the buffer changes while the LLM is responding, its edits are discarded. If the buffer is closed, its reply is discarded too.
  • When continuing a conversation with an HTTP adapter, the earlier turns count towards the model's input limit. Fewer lines of the buffer are shared as the conversation grows, and once your selection no longer fits, you need to start a new conversation.

Released under the Apache-2.0 License.