A lightweight, powerful multi-cursor plugin for Neovim that feels like VS Code's multi-cursor implementation.
- Position-Based Selection: Select or skip specific matches based on your cursor position.
- Real-time Sync: Edits (insert, delete, change) are synchronized across all cursors instantly.
- Smart Navigation:
Ctrl+J/Ctrl+Kto jump between matches quickly. - Auto-Jump: Automatically moves to the next unselected match after you select or skip one.
- Preserved State: Keeps track of skipped matches so you can come back to them.
Using lazy.nvim
{
"khoido2003/multiple-cursor.nvim",
keys = {
{ "<C-n>", "<cmd>MultipleCursorStart<cr>", desc = "Start Multiple Cursor" },
},
cmd = { "MultipleCursorStart", "MultipleCursorSelectAll" },
config = function()
require("multiple-cursor").setup()
end,
}Using packer.nvim
use {
"khoido2003/multiple-cursor.nvim",
config = function()
require("multiple-cursor").setup()
end,
}Clone to your Neovim packages directory:
git clone https://github.com/khoido2003/multiple-cursor.nvim ~/.local/share/nvim/site/pack/plugins/start/multiple-cursor| Key | Action | Description |
|---|---|---|
<C-n> |
Add Cursor | Adds a cursor to the match under your current cursor position. If no session is active, starts one on the current word. |
<C-x> |
Skip / Remove | Skips or removes the cursor from the match under your current position. |
<C-j> |
Next Match | Jump to the next match occurrence. |
<C-k> |
Prev Match | Jump to the previous match occurrence. |
<C-a> |
Select All | Selects all remaining matches in the buffer. |
c / i / I / A |
Edit | Enter edit mode. Changes are synced to all selected cursors. |
<Esc> |
Exit | Exit multi-cursor mode. |
- Place your cursor on a word you want to edit.
- Press
<C-n>to start. The current word is selected and the cursor jumps to the next match. - Use
<C-j>/<C-k>to move between matches if needed. - Press
<C-n>to add more cursors, or<C-x>to skip a match. - Press
c(change),d(delete), ori(insert) to start editing. All selected instances will be updated simultaneously. - Press
<Esc>to finish.
Default configuration:
require("multiple-cursor").setup({
keymaps = {
start_next = "<C-n>",
skip = "<C-x>",
next_match = "<C-j>",
prev_match = "<C-k>",
select_all = "<C-a>",
exit = "<Esc>",
},
highlights = {
cursor = "MultipleCursor",
match = "MultipleCursorMatch",
current = "MultipleCursorCurrent",
skipped = "MultipleCursorSkipped",
},
highlight_definitions = {
cursor = { bg = "#50fa7b", fg = "#000000", bold = true }, -- Vivid Green with Black text
match = { bg = "#f1fa8c", fg = "#000000", bold = true }, -- Bright Yellow with Black text
current = { bg = "#8be9fd", fg = "#000000", bold = true }, -- Cyan with Black text
skipped = { bg = "#ff5555", fg = "#000000", strikethrough = true }, -- Red with Black text
},
match_whole_word = true,
case_sensitive = true,
})