To get out of multiple-cursors-mode, press <return> or C-g. The latter will
first disable multiple regions before disabling multiple cursors. If you want to
insert a newline in multiple-cursors-mode, use C-j.

Mark many occurrences

mc/edit-beginnings-of-lines: Adds a cursor at the start of each line in the current region.

mc/edit-ends-of-lines: Adds a cursor at the end of each line in the current region.

mc/mark-all-like-this: Marks all parts of the buffer that matches the current region.

mc/mark-all-words-like-this: Like mc/mark-all-like-this but only for whole words.

mc/mark-all-symbols-like-this: Like mc/mark-all-like-this but only for whole symbols.

mc/mark-all-in-region: Prompts for a string to match in the region, adding cursors to all of them.

mc/mark-all-like-this-in-defun: Marks all parts of the current defun that matches the current region.

mc/mark-all-words-like-this-in-defun: Like mc/mark-all-like-this-in-defun but only for whole words.

mc/mark-all-symbols-like-this-in-defun: Like mc/mark-all-like-this-in-defun but only for whole symbols.

mc/mark-all-dwim: Tries to be smart about marking everything you want. Can be pressed multiple times.

Special

set-rectangular-region-anchor: Think of this one as set-mark except you're marking a rectangular region.

mc/mark-sgml-tag-pair: Mark the current opening and closing tag.

mc/insert-numbers: Insert increasing numbers for each cursor, top to bottom.

mc/sort-regions: Sort the marked regions alphabetically.

mc/reverse-regions: Reverse the order of the marked regions.

Tips and tricks

To get out of multiple-cursors-mode, press <return> or C-g. The latter will
first disable multiple regions before disabling multiple cursors. If you want to
insert a newline in multiple-cursors-mode, use C-j.

Sometimes you end up with cursors outside of your view. You can
scroll the screen to center on each cursor with C-v and M-v or you can
press C-' to hide all lines without a cursor, press C-' again to unhide.

Try pressing mc/mark-next-like-this with no region selected. It
will just add a cursor on the next line.

Try pressing mc/mark-all-like-this-dwim on a tagname in html-mode.

Notice that the number of cursors active can be seen in the modeline.

If you get out of multiple-cursors-mode and yank - it will yank only
from the kill-ring of main cursor. To yank from the kill-rings of
every cursor use yank-rectangle, normally found at C-x r y.

You can use mc/reverse-regions with nothing selected and just one cursor.
It will then flip the sexp at point and the one below it.

When you use mc/edit-lines, you can give it a positive or negative
prefix to change how it behaves on too short lines.

If you would like to keep the global bindings clean, and get custom keybindings
when the region is active, you can try region-bindings-mode.

BTW, I highly recommend adding mc/mark-next-like-this to a key binding that's
right next to the key for er/expand-region.

Binding mouse events

To override a mouse event, you will likely have to also unbind the
down-mouse part of the event. Like this:

Or you can do like me and find an unused, but less convenient, binding:

(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)

Unknown commands

Multiple-cursors uses two lists of commands to know what to do: the run-once list
and the run-for-all list. It comes with a set of defaults, but it would be beyond silly
to try and include all the known Emacs commands.

So that's why multiple-cursors occasionally asks what to do about a command. It will
then remember your choice by saving it in ~/.emacs.d/.mc-lists.el. You can change
the location with:

(setq mc/list-file "/my/preferred/file")

NB! Make sure to do so before requiring multiple-cursors.

Known limitations

isearch-forward and isearch-backward aren't supported with multiple cursors.
If you want this functionality, you can use phi-search.

Commands run with M-x won't be repeated for all cursors.

All key bindings that refer to lambdas are always run for all cursors. If you
need to limit it, you will have to give it a name.

Redo might screw with your cursors. Undo works very well.

Contribute

Yes, please do. There's a suite of tests, so remember to add tests for your
specific feature, or I might break it later.

You'll find the repo at:

https://github.com/magnars/multiple-cursors.el

To fetch the test dependencies, install
cask if you haven't already,
then:

License

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.