@@ -49,40 +49,40 @@ Continue reading for a guide of how to use the default config.
49
49
config = function()
50
50
local mc = require("multicursor-nvim")
51
51
mc.setup()
52
-
52
+
53
53
local set = vim.keymap.set
54
-
54
+
55
55
-- Add or skip cursor above/below the main cursor.
56
56
set({"n", "x"}, "<up> ", function() mc.lineAddCursor(-1) end)
57
57
set({"n", "x"}, "<down> ", function() mc.lineAddCursor(1) end)
58
58
set({"n", "x"}, "<leader><up> ", function() mc.lineSkipCursor(-1) end)
59
59
set({"n", "x"}, "<leader><down> ", function() mc.lineSkipCursor(1) end)
60
-
60
+
61
61
-- Add or skip adding a new cursor by matching word/selection
62
62
set({"n", "x"}, "<leader> n", function() mc.matchAddCursor(1) end)
63
63
set({"n", "x"}, "<leader> s", function() mc.matchSkipCursor(1) end)
64
64
set({"n", "x"}, "<leader> N", function() mc.matchAddCursor(-1) end)
65
65
set({"n", "x"}, "<leader> S", function() mc.matchSkipCursor(-1) end)
66
-
66
+
67
67
-- Add and remove cursors with control + left click.
68
68
set("n", "<c-leftmouse> ", mc.handleMouse)
69
69
set("n", "<c-leftdrag> ", mc.handleMouseDrag)
70
70
set("n", "<c-leftrelease> ", mc.handleMouseRelease)
71
-
71
+
72
72
-- Disable and enable cursors.
73
73
set({"n", "x"}, "<c-q> ", mc.toggleCursor)
74
-
74
+
75
75
-- Mappings defined in a keymap layer only apply when there are
76
76
-- multiple cursors. This lets you have overlapping mappings.
77
77
mc.addKeymapLayer(function(layerSet)
78
-
78
+
79
79
-- Select a different cursor as the main one.
80
80
layerSet({"n", "x"}, "<left> ", mc.prevCursor)
81
81
layerSet({"n", "x"}, "<right> ", mc.nextCursor)
82
-
82
+
83
83
-- Delete the main cursor.
84
84
layerSet({"n", "x"}, "<leader> x", mc.deleteCursor)
85
-
85
+
86
86
-- Enable and clear cursors using escape.
87
87
layerSet("n", "<esc> ", function()
88
88
if not mc.cursorsEnabled() then
@@ -92,7 +92,7 @@ Continue reading for a guide of how to use the default config.
92
92
end
93
93
end)
94
94
end)
95
-
95
+
96
96
-- Customize how cursors look.
97
97
local hl = vim.api.nvim_set_hl
98
98
hl(0, "MultiCursorCursor", { reverse = true })
@@ -229,7 +229,7 @@ mc.toggleCursor() *multicursor-toggleCursor*
229
229
230
230
231
231
mc.lineAddCursor(direction) *multicursor-lineAddCursor*
232
- Add a cursor above or below the the main cursor, skipping empty lines,
232
+ Add a cursor above or below the main cursor, skipping empty lines,
233
233
specified by `direction` .
234
234
235
235
Usage example: >lua
@@ -390,7 +390,7 @@ mc.hasCursors() *multicursor-hasCursors*
390
390
391
391
392
392
mc.deleteCursor() *multicursor-deleteCursor*
393
- Delete the main cursor.
393
+ Delete the main cursor, the main cursor is now the previous cursor .
394
394
395
395
Usage example: >lua
396
396
vim.keymap.set({"n", "v"}, "<leader> x", mc.deleteCursor)
@@ -439,18 +439,23 @@ mc.alignCursors() *multicursor-alignCursors*
439
439
<
440
440
441
441
mc.splitCursors() *multicursor-splitCursors*
442
- Split visual selections with a regex separator. For example, visually
443
- selecting "a,b,c,d" and splitting with "," will create four cursors, one
444
- on each letter.
442
+ Interactively ask for a regex separator, split every visual selections
443
+ with the regex separator. To be used in visual/select mode only.
444
+
445
+ For example, visually selecting "ab,cd,ef,gh" and splitting with "," will
446
+ create four cursors, each selecting a group of letters.
445
447
446
448
Usage example: >lua
447
449
vim.keymap.set("v", "S", mc.splitCursors)
448
450
<
449
451
450
452
mc.matchCursors() *multicursor-matchCursors*
451
- Match a pattern over a visual selection, creating a new cursor for each
452
- match. For example, visually selecting "foo bar foo" and matching with
453
- "foo" will create two cursors, one on each "foo".
453
+ Interactively ask for a pattern, add a cursor for each match of this
454
+ pattern over every visual selections.
455
+ To be used in visual/select mode only.
456
+
457
+ For example, visually selecting "foo bar foo" and matching with "foo" will
458
+ create two cursors, one on each "foo".
454
459
455
460
Usage example: >lua
456
461
vim.keymap.set("v", "M", mc.matchCursors)
@@ -529,20 +534,23 @@ mc.sequenceDecrement() *multicursor-sequenceDecrement*
529
534
<
530
535
531
536
mc.addCursorOperator() *multicursor-addCursorOperator*
532
- Takes a motion and adds a cursor for each line. For example, if it is
533
- mapped to `ga` , then typing `gaip` will add a cursor for every line in
534
- the current paragraph.
537
+ Takes a motion and adds a cursor for every lines.
538
+
539
+ For example, if it is mapped to `ga` , then typing `gaip` will add a cursor
540
+ for every line in the current paragraph.
535
541
536
542
Usage example: >lua
537
543
vim.keymap.set("n", "ga", mc.addCursorOperator)
538
544
<
539
545
540
546
mc.operator(opts?) *multicursor-operator*
541
547
Adds a cursor for every match found in a region. The text to match is
542
- given by a motion, and the region is given by a second motion. For
543
- example, if mapped to `<leader> m ` then `<leader> miwap` will find every
544
- match within the paragraph of the text contained within `iw` . If called
545
- from visual mode, the selection becomes the first motion's target text.
548
+ given by a motion, and the region is given by a second motion.
549
+
550
+ For example, if mapped to `<leader> m ` then `<leader> miwap` will find every
551
+ match within the paragraph of the text contained within `iw` .
552
+ If called from visual mode, the selection becomes the first motion's
553
+ target text.
546
554
547
555
Usage example: >lua
548
556
vim.keymap.set({ "x", "n" }, "<leader> m", mc.operator)
@@ -636,7 +644,7 @@ mc.disableCursors() *multicursor-disableCursors*
636
644
637
645
638
646
mc.enableCursors() *multicursor-enableCursors*
639
- Unlocks the cursors from moving .
647
+ Unlocks disabled cursors, currently active cursors will be discarded .
640
648
641
649
Usage example: >lua
642
650
vim.keymap.set({"n", "v"}, "<c-q> ", mc.enableCursors)
@@ -673,9 +681,10 @@ mc.feedkeys({keys}, {opts?}) *multicursor-feedkeys*
673
681
674
682
675
683
mc.addKeymapLayer(callback) *multicursor-addKeymapLayer*
676
- Calls the `callback` when there are multiple cursors. Any mappings set
677
- with the provided function are automatically removed once multicursor
678
- ends.
684
+ Registers a keymap layer callback.
685
+ It will be called when a buffer has cursors, any mappings set with the
686
+ provided function (similar to `vim .keymap .set ` ) will be automatically
687
+ removed once multicursor ends.
679
688
680
689
Usage example: >lua
681
690
mc.addKeymapLayer(function(layerSet)
@@ -1290,6 +1299,17 @@ Cursor:setRedoChangePos(pos) *multicursor-cursor-setRedoChangePos*
1290
1299
• | multicursor-types-Pos |
1291
1300
1292
1301
1302
+ Cursor:setUndoChangePos(pos) *multicursor-cursor-setUndoChangePos*
1303
+ Sets the position of the undo position marker.
1304
+
1305
+ Parameters: ~
1306
+ • {pos} (`Pos` ) new position cursor should have when undoing.
1307
+
1308
+ See also: ~
1309
+ • | multicursor-types-SimplePos |
1310
+ • | multicursor-types-Pos |
1311
+
1312
+
1293
1313
Cursor:registerUndo() *multicursor-cursor-registerUndo*
1294
1314
Registers this cursor so that its original position is restored upon undo.
1295
1315
@@ -1389,9 +1409,10 @@ Cursor:enable() *multicursor-cursor-enable*
1389
1409
1390
1410
1391
1411
Cursor:feedkeys(keys, opts?) *multicursor-cursor-feedkeys*
1392
- Makes the cursor perform a command/commands. For example,
1393
- `cursor : feedkeys (' dw' )` will delete a word. By default, keys are not
1394
- remapped and keycodes are not parsed.
1412
+ Makes the cursor perform a command/commands.
1413
+
1414
+ For example, `cursor : feedkeys (' dw' )` will delete a word. By default, keys
1415
+ are not remapped and keycodes are not parsed.
1395
1416
1396
1417
Parameters: ~
1397
1418
• {keys} (`string ` ) string representing a command
0 commit comments