this repo has no description
at main 3.3 kB view raw
1return { 2 "jake-stewart/multicursor.nvim", 3 branch = "1.0", 4 config = function() 5 local mc = require("multicursor-nvim") 6 7 mc.setup() 8 9 local set = vim.keymap.set 10 11 -- Add or skip cursor above/below the main cursor. 12 set({ "n", "v" }, "<up>", function() 13 mc.lineAddCursor(-1) 14 end) 15 set({ "n", "v" }, "<down>", function() 16 mc.lineAddCursor(1) 17 end) 18 set({ "n", "v" }, "<leader><up>", function() 19 mc.lineSkipCursor(-1) 20 end) 21 set({ "n", "v" }, "<leader><down>", function() 22 mc.lineSkipCursor(1) 23 end) 24 25 -- Add or skip adding a new cursor by matching word/selection 26 set({ "n", "v" }, "<leader>n", function() 27 mc.matchAddCursor(1) 28 end) 29 set({ "n", "v" }, "<leader>s", function() 30 mc.matchSkipCursor(1) 31 end) 32 set({ "n", "v" }, "<leader>N", function() 33 mc.matchAddCursor(-1) 34 end) 35 set({ "n", "v" }, "<leader>S", function() 36 mc.matchSkipCursor(-1) 37 end) 38 39 -- Add all matches in the document 40 set({ "n", "v" }, "<leader>A", mc.matchAllAddCursors) 41 42 -- You can also add cursors with any motion you prefer: 43 -- set("n", "<right>", function() 44 -- mc.addCursor("w") 45 -- end) 46 -- set("n", "<leader><right>", function() 47 -- mc.skipCursor("w") 48 -- end) 49 50 -- Rotate the main cursor. 51 set({ "n", "v" }, "<left>", mc.nextCursor) 52 set({ "n", "v" }, "<right>", mc.prevCursor) 53 54 -- Delete the main cursor. 55 set({ "n", "v" }, "<leader>x", mc.deleteCursor) 56 57 -- Add and remove cursors with control + left click. 58 set("n", "<c-leftmouse>", mc.handleMouse) 59 60 -- Easy way to add and remove cursors using the main cursor. 61 set({ "n", "v" }, "<c-q>", mc.toggleCursor) 62 63 -- Clone every cursor and disable the originals. 64 set({ "n", "v" }, "<leader><c-q>", mc.duplicateCursors) 65 66 set("n", "<esc>", function() 67 if not mc.cursorsEnabled() then 68 mc.enableCursors() 69 elseif mc.hasCursors() then 70 mc.clearCursors() 71 else 72 -- Default <esc> handler. 73 end 74 end) 75 76 -- bring back cursors if you accidentally clear them 77 set("n", "<leader>gv", mc.restoreCursors) 78 79 -- Align cursor columns. 80 set("n", "<leader>a", mc.alignCursors) 81 82 -- Split visual selections by regex. 83 set("v", "S", mc.splitCursors) 84 85 -- Append/insert for each line of visual selections. 86 set("v", "I", mc.insertVisual) 87 set("v", "A", mc.appendVisual) 88 89 -- match new cursors within visual selections by regex. 90 set("v", "M", mc.matchCursors) 91 92 -- Rotate visual selection contents. 93 set("v", "<leader>t", function() 94 mc.transposeCursors(1) 95 end) 96 set("v", "<leader>T", function() 97 mc.transposeCursors(-1) 98 end) 99 100 -- Jumplist support 101 set({ "v", "n" }, "<c-i>", mc.jumpForward) 102 set({ "v", "n" }, "<c-o>", mc.jumpBackward) 103 104 -- Customize how cursors look. 105 local hl = vim.api.nvim_set_hl 106 hl(0, "MultiCursorCursor", { link = "Cursor" }) 107 hl(0, "MultiCursorVisual", { link = "Visual" }) 108 hl(0, "MultiCursorSign", { link = "SignColumn" }) 109 hl(0, "MultiCursorDisabledCursor", { link = "Visual" }) 110 hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) 111 hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) 112 end, 113}