gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
388 stars 36 forks source link
emacs evil multiple-cursors vim

: ▓█████ ██▒ █▓ ██▓ ██▓ ███▄ ▄███▓ ▄████▄
: ▓█ ▀▓██░ █▒▓██▒▓██▒ ▓██▒▀█▀ ██▒▒██▀ ▀█
: ▒███ ▓██ █▒░▒██▒▒██░ ▓██ ▓██░▒▓█ ▄ : ▒▓█ ▄ ▒██ █░░░██░▒██░ ▒██ ▒██ ▒▓▓▄ ▄██▒ : ░▒████▒ ▒▀█░ ░██░░██████▒ ▒██▒ ░██▒▒ ▓███▀ ░ : ░░ ▒░ ░ ░ ▐░ ░▓ ░ ▒░▓ ░ ░ ▒░ ░ ░░ ░▒ ▒ ░ : ░ ░ ░ ░ ░░ ▒ ░░ ░ ▒ ░ ░ ░ ░ ░ ▒
: ░ ░░ ▒ ░ ░ ░ ░ ░ ░
: ░ ░ ░ ░ ░ ░ ░ ░ ░
: ░ ░

[[https://travis-ci.org/gabesoft/evil-mc][https://travis-ci.org/gabesoft/evil-mc.svg?branch=master]] [[http://melpa.org/#/evil-mc][file:http://melpa.org/packages/evil-mc-badge.svg?style=flat-square]] [[http://melpa.org/#/evil-mc][file:http://stable.melpa.org/packages/evil-mc-badge.svg?style=flat-square]]

Multiple cursors implementation for evil-mode ** Synopsis evil-mc provides multiple cursors functionality for Emacs when used with evil-mode Usage Start with:

+BEGIN_SRC emacs-lisp

(require 'evil-mc)

+END_SRC

*** Local Setup To enable or disable evil-mc* mode for a single buffer use:\

+BEGIN_SRC emacs-lisp

(evil-mc-mode 1) ;; enable (evil-mc-mode -1) ;; disable

+END_SRC

*** Global Setup To enable or disable evil-mc* mode for all buffers use:\

+BEGIN_SRC emacs-lisp

(global-evil-mc-mode 1) ;; enable (global-evil-mc-mode -1) ;; disable

+END_SRC

**** Basic Usage The main commands used to create or delete cursors are:

+BEGIN_SRC emacs-lisp

(evil-mc-make-all-cursors) ;; Create cursors for all strings that match the selected ;; region or the symbol under cursor.

(evil-mc-undo-all-cursors) ;; Remove all cursors.

(evil-mc-make-and-goto-next-match) ;; Make a cursor at point and go to the next match of the ;; selected region or the symbol under cursor.

(evil-mc-skip-and-goto-next-match) ;; Go to the next match of the selected region or the symbol under ;; cursor without creating a cursor at point.

+END_SRC

The above commands as well as others, detailed below, are setup with key bindings when the evil-mc mode is enabled. The keys are defined in ~evil-mc-key-map~. You can take a look at that variable declaration in [[https://github.com/gabesoft/evil-mc/blob/master/evil-mc.el][evil-mc.el]] to see all key bindings. But, in short, ~C-n~ / ~C-p~ are used for creating cursors, and ~M-n~ / ~M-p~ are used for cycling through cursors. The commands that create cursors wrap around; but, the ones that cycle them do not. To skip creating a cursor forward use ~C-t~ or ~grn~ and backward ~grp~. Finally use ~gru~ to "undo" the last added cursor, and ~grq~ to remove all cursors.

Optionally set up visual mode keybindings for ~I~ and ~A~ to create cursors at the beginning or end of every visually selected line.

+BEGIN_SRC emacs-lisp

(evil-define-key 'visual evil-mc-key-map "A" #'evil-mc-make-cursor-in-visual-selection-end "I" #'evil-mc-make-cursor-in-visual-selection-beg)

+END_SRC

For an example of setting up evil-mc see this [[https://github.com/gabesoft/evil-mc/blob/master/evil-mc-setup.el][setup file]] **** Commands Here's a detailed list of all commands used to create, navigate through, or delete cursors:\ /All the commands below assume that there is a real cursor and possibly some fake cursors./

+BEGIN_SRC emacs-lisp

(evil-mc-make-all-cursors) ;; Make a cursor for every match of the selected region or the symbol at point.

(evil-mc-undo-all-cursors) ;; Remove all cursors.

(evil-mc-undo-last-added-cursor) ;; Remove the last added cursor and move point to its position.

(evil-mc-make-and-goto-next-match) ;; Make a cursor at point, and go to the next match of the ;; selected region or the symbol at point.

(evil-mc-make-and-goto-prev-match) ;; Make a cursor at point, and go to the previous match of the ;; selected region or the symbol at point.

(evil-mc-skip-and-goto-next-match) ;; Go to the next match of the selected region or symbol at point ;; without making a cursor at point. This command can be used to ;; remove unwanted cursors.

(evil-mc-skip-and-goto-prev-match) ;; Go to the previous match of the selected region or symbol at point ;; without making a cursor at point. This command can be used to ;; remove unwanted cursors.

(evil-mc-make-and-goto-prev-cursor) ;; Make a cursor at point and move point to the cursor ;; closest to it when searching backwards.

(evil-mc-make-and-goto-next-cursor) ;; Make a cursor at point and move point to the cursor ;; closest to it when searching forwards.

(evil-mc-skip-and-goto-prev-cursor) ;; Move point to the cursor closest to it when searching backwards ;; without making a cursor at point. This command can be used to ;; remove unwanted cursors.

(evil-mc-skip-and-goto-next-cursor) ;; Move point to the cursor closest to it when searching forwards ;; without making a cursor at point. This command can be used to ;; remove unwanted cursors.

(evil-mc-make-and-goto-first-cursor) ;; Make a cursor at point and move point to the cursor at the first position.

(evil-mc-make-and-goto-last-cursor) ;; Make a cursor at point and move point to the cursor at the last position.

(evil-mc-make-cursor-here) ;; Create a cursor at point. This command should be used with `evil-mc-pause-cursors'.

(evil-mc-pause-cursors) ;; Pause all fake cursors. This can be used with `evil-mc-make-cursor-here'

(evil-mc-resume-cursors) ;; Call to resume paused cursors.

(evil-mc-make-cursor-in-visual-selection-beg) ;; Create cursors at the beginning of every visually selected line.

(evil-mc-make-cursor-in-visual-selection-end) ;; Create cursors at the end of every visually selected line.

+END_SRC

*** Customization evil-mc* can be customized in several ways:

*** Mode line text and colors There are 4 variables, that can change the mode lines text, and its color.

**** Only one cursor The ~emc~ text can be hidden, by setting this variable to ~nil~. (default: ~t~)

+BEGIN_SRC

(setq evil-mc-one-cursor-show-mode-line-text t)

+END_SRC

**** Two or more cursors, resumed (unpaused) The resumed mode line text, can have two different colors:

**** Two or more cursors, paused The ~(paused)~ text can be hidden, by setting this variable to ~nil~. (default: ~t~)

+BEGIN_SRC

(setq evil-mc-mode-line-text-paused t)

+END_SRC

The paused mode line text can have three different colors:

*** Notes

**** Debugging

**** Limitations

**** Known issues