Skip to main content

Overview

Avante.nvim provides powerful diff management capabilities inspired by git-conflict.nvim. When the AI suggests code changes, you can review and selectively apply them using intuitive keybindings.

Diff Conflict Keybindings

When viewing AI-suggested changes, you’ll see conflicts between your current code (“ours”) and the AI’s suggestions (“theirs”). Use these keybindings to resolve conflicts:

Primary Actions

Key BindingDescription
coChoose Ours - Keep your current code
ctChoose Theirs - Accept AI’s suggestion
cbChoose Both - Keep both versions
caChoose All Theirs - Accept all AI suggestions
ccChoose Cursor - Use version under cursor
Key BindingDescription
]xNext Conflict - Jump to next conflict
[xPrevious Conflict - Jump to previous conflict
These keybindings are inspired by vim-fugitive’s merge conflict resolution patterns, making them familiar to vim users.

Customizing Diff Keybindings

You can customize all diff-related keybindings in your configuration:
require('avante').setup({
  mappings = {
    diff = {
      ours = "co",        -- Choose current code
      theirs = "ct",      -- Choose AI suggestion
      all_theirs = "ca",  -- Accept all suggestions
      both = "cb",        -- Keep both
      cursor = "cc",      -- Use cursor version
      next = "]x",        -- Next conflict
      prev = "[x",        -- Previous conflict
    },
  },
})

Custom Keybinding Example

-- Use different keybindings
require('avante').setup({
  mappings = {
    diff = {
      ours = "<leader>do",
      theirs = "<leader>dt",
      both = "<leader>db",
      next = "<C-j>",
      prev = "<C-k>",
    },
  },
})

Auto-Jump Feature

Avante can automatically jump to the first conflict when applying diffs:
require('avante').setup({
  diff = {
    autojump = true, -- Automatically jump to first conflict
  },
})
autojump
boolean
default:"true"
When enabled, automatically jumps to the first conflict after a diff is applied

Timeout Configuration

To avoid conflicts with vim’s operator-pending mode, Avante can override the timeoutlen setting while hovering over a diff:
require('avante').setup({
  diff = {
    override_timeoutlen = 500, -- Override timeoutlen (in ms)
  },
})
override_timeoutlen
number
default:"500"
Override the timeoutlen setting while hovering over a diff to avoid entering operator-pending mode. Set to -1 to disable.
This helps prevent accidentally triggering vim’s operator-pending mode when using diff mappings that start with c.

Diff Highlights

Customize how diffs are highlighted:
require('avante').setup({
  highlights = {
    diff = {
      current = "DiffText",   -- Highlight for "ours" (current code)
      incoming = "DiffAdd",    -- Highlight for "theirs" (AI suggestions)
    },
  },
})

Available Highlight Groups

Highlight GroupDescriptionDefault
AvanteConflictCurrentCurrent code highlightDiffText
AvanteConflictIncomingAI suggestion highlightDiffAdd
AvanteConflictCurrentLabelCurrent code labelShade of AvanteConflictCurrent
AvanteConflictIncomingLabelAI suggestion labelShade of AvanteConflictIncoming

List Opener

Configure how the conflict list is opened:
require('avante').setup({
  diff = {
    list_opener = "copen", -- Command to open conflict list
  },
})
You can also use a function:
require('avante').setup({
  diff = {
    list_opener = function()
      vim.cmd("botright copen")
    end,
  },
})

Focus After Apply

Control which diff to focus after applying changes:
require('avante').setup({
  windows = {
    ask = {
      focus_on_apply = "ours", -- "ours" or "theirs"
    },
  },
})
focus_on_apply
string
default:"ours"
Which diff to focus after applying. Options:
  • "ours" - Focus on your current code
  • "theirs" - Focus on AI’s suggestion

Minimize Diff

Remove unchanged lines when applying code blocks:
require('avante').setup({
  behaviour = {
    minimize_diff = true, -- Remove unchanged lines
  },
})
Enabling minimize_diff makes it easier to focus on actual changes by hiding unchanged code.

Workflow Example

1

Request AI Changes

Ask the AI to modify your code using :AvanteAsk or :AvanteEdit.
2

Review Conflicts

The AI’s suggestions appear as conflicts. Review the differences between “ours” (current) and “theirs” (AI).
3

Navigate Conflicts

Use ]x and [x to jump between conflicts.
4

Resolve Conflicts

For each conflict, choose:
  • co - Keep your version
  • ct - Accept AI’s version
  • cb - Keep both
  • cc - Use version under cursor
5

Apply All (Optional)

Use ca to accept all AI suggestions at once, or A in the sidebar to apply all changes.

Auto-Apply Mode

For faster workflows, enable auto-apply to skip conflict resolution:
require('avante').setup({
  behaviour = {
    auto_apply_diff_after_generation = true, -- Auto-apply diffs
  },
})
Auto-apply mode will automatically apply all AI suggestions without review. Use with caution.

Tips and Tricks

Quick Accept

Use ca to quickly accept all AI suggestions if you trust the changes.

Selective Review

Navigate with ]x/[x to review each conflict individually before deciding.

Hybrid Approach

Use cb to keep both versions when you want to merge ideas manually.

Cursor Control

Position your cursor on the preferred version and use cc for quick resolution.

Troubleshooting

  1. Ensure behaviour.auto_set_keymaps = true in your config
  2. Check for keybinding conflicts with other plugins
  3. Verify you’re in the diff buffer when pressing keys
  1. Ensure behaviour.auto_set_highlight_group = true
  2. Check your colorscheme supports diff highlights
  3. Try customizing highlights.diff settings
Verify diff.autojump = true in your configuration.

Keybindings

View all available keybindings

Usage Guide

Learn basic Avante workflows

Highlights

Customize visual appearance

Build docs developers (and LLMs) love