Add magnars's multiple-cursors backend
This commit is contained in:
parent
b4907d0540
commit
d68c6311d6
3 changed files with 89 additions and 5 deletions
|
@ -1775,6 +1775,17 @@ Other:
|
||||||
**** Multiple Cursors
|
**** Multiple Cursors
|
||||||
- Disabled Spacemacs paste transient state when pasting to avoid pasting issue
|
- Disabled Spacemacs paste transient state when pasting to avoid pasting issue
|
||||||
when there are more than one cursor (thanks to braham-snyder)
|
when there are more than one cursor (thanks to braham-snyder)
|
||||||
|
- Added magnars's multiple-cursors package as a new backend (thanks to bb2020)
|
||||||
|
- ~SPC s m a~ =mc/mark-all-dwim=
|
||||||
|
- ~SPC s m b~ =mc/mark-all-like-this=
|
||||||
|
- ~SPC s m m~ =mc/mark-more-like-this-extended=
|
||||||
|
- ~SPC s m r~ =mc/edit-lines=
|
||||||
|
- ~SPC s m s l~ =mc/insert-letters=
|
||||||
|
- ~SPC s m s m~ =mc/mark-sgml-tag-pair=
|
||||||
|
- ~SPC s m s n~ =mc/insert-numbers=
|
||||||
|
- ~SPC s m s r~ =set-rectangular-region-anchor=
|
||||||
|
- ~SPC s m s s~ =mc/sort-regions=
|
||||||
|
- ~SPC s m s t~ =mc/reverse-regions=
|
||||||
**** Neotree
|
**** Neotree
|
||||||
- Made neotree an optional instead of a default layer
|
- Made neotree an optional instead of a default layer
|
||||||
- Move neotree to its own layer in new +filetree folder
|
- Move neotree to its own layer in new +filetree folder
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
- [[#configuration][Configuration]]
|
- [[#configuration][Configuration]]
|
||||||
- [[#key-bindings][Key bindings]]
|
- [[#key-bindings][Key bindings]]
|
||||||
- [[#evil-mc][=evil-mc=]]
|
- [[#evil-mc][=evil-mc=]]
|
||||||
|
- [[#multiple-cursors][=multiple-cursors=]]
|
||||||
|
- [[#notes][Notes]]
|
||||||
|
- [[#multiple-cursors-1][=multiple-cursors=]]
|
||||||
|
|
||||||
* Description
|
* Description
|
||||||
** Features:
|
** Features:
|
||||||
|
@ -20,12 +23,16 @@ add =multiple-cursors= to the existing =dotspacemacs-configuration-layers= list
|
||||||
file.
|
file.
|
||||||
|
|
||||||
* Configuration
|
* Configuration
|
||||||
Currently the only supported backend is =evil-mc=, but more backends will be
|
Currently supported backends are:
|
||||||
available in the future.
|
- [[https://github.com/gabesoft/evil-mc][evil-mc]] (default)
|
||||||
|
- [[https://github.com/magnars/multiple-cursors.el][mc]]
|
||||||
|
|
||||||
|
To set your choice of backend, configure =multiple-cursors-backend= variable of
|
||||||
|
the layer.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(setq-default dotspacemacs-configuration-layers '(
|
(setq-default dotspacemacs-configuration-layers '(
|
||||||
(multiple-cursors :variables multiple-cursors-backend 'evil-mc))
|
(multiple-cursors :variables multiple-cursors-backend 'mc))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Key bindings
|
* Key bindings
|
||||||
|
@ -60,3 +67,44 @@ For easy navigation you also have the following:
|
||||||
| ~C-t~ | evil-mc-skip-and-goto-next-match |
|
| ~C-t~ | evil-mc-skip-and-goto-next-match |
|
||||||
| ~C-M-j~ | evil-mc-make-cursor-move-next-line |
|
| ~C-M-j~ | evil-mc-make-cursor-move-next-line |
|
||||||
| ~C-M-k~ | evil-mc-make-cursor-move-prev-line |
|
| ~C-M-k~ | evil-mc-make-cursor-move-prev-line |
|
||||||
|
|
||||||
|
** =multiple-cursors=
|
||||||
|
The =multiple-cursors= backend provides the following key bindings to
|
||||||
|
insert new cursors:
|
||||||
|
|
||||||
|
| Key binding | Description |
|
||||||
|
|-------------+---------------------------------|
|
||||||
|
| ~SPC s m a~ | mc/mark-all-dwim |
|
||||||
|
| ~SPC s m b~ | mc/mark-all-like-this |
|
||||||
|
| ~SPC s m m~ | mc/mark-more-like-this-extended |
|
||||||
|
| ~SPC s m r~ | mc/edit-lines |
|
||||||
|
|
||||||
|
These special bindings manipulate text under cursors:
|
||||||
|
|
||||||
|
| Key binding | Description |
|
||||||
|
|---------------+-------------------------------|
|
||||||
|
| ~SPC s m s l~ | mc/insert-letters |
|
||||||
|
| ~SPC s m s m~ | mc/mark-sgml-tag-pair |
|
||||||
|
| ~SPC s m s n~ | mc/insert-numbers |
|
||||||
|
| ~SPC s m s r~ | set-rectangular-region-anchor |
|
||||||
|
| ~SPC s m s s~ | mc/sort-regions |
|
||||||
|
| ~SPC s m s t~ | mc/reverse-regions |
|
||||||
|
|
||||||
|
* Notes
|
||||||
|
** =multiple-cursors=
|
||||||
|
Some commands executed during =multiple-cursors= enabled may lead Emacs to go frenzy.
|
||||||
|
Commands like window manipulation will be executed multiple times if =mc= is active.
|
||||||
|
Not all Emacs commands may be compatible with =mc=.
|
||||||
|
|
||||||
|
To run interactive ~M-x~ commands with =mc=, run the command first. This will result
|
||||||
|
with application of the command to the leading cursor. Then press =C-:= to apply the
|
||||||
|
command to consequtive cursors. If this is not the case or you want a command to be
|
||||||
|
executed only once, configure the =mc/cmds-to-run-once= variable of the layer like
|
||||||
|
in the following example.
|
||||||
|
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(setq-default dotspacemacs-configuration-layers '(
|
||||||
|
(multiple-cursors :variables
|
||||||
|
multiple-cursors-backend 'mc
|
||||||
|
mc/cmds-to-run-once '(upcase-region))))
|
||||||
|
#+END_SRC
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
(setq multiple-cursors-packages
|
(setq multiple-cursors-packages
|
||||||
'(
|
'(
|
||||||
evil-mc
|
(evil-mc :toggle (eq multiple-cursors-backend 'evil-mc))
|
||||||
))
|
(multiple-cursors :toggle (eq multiple-cursors-backend 'mc))))
|
||||||
|
|
||||||
(defun multiple-cursors/init-evil-mc ()
|
(defun multiple-cursors/init-evil-mc ()
|
||||||
(use-package evil-mc
|
(use-package evil-mc
|
||||||
|
@ -34,3 +34,28 @@
|
||||||
(define-key state-map (car keybinding) (cdr keybinding))))
|
(define-key state-map (car keybinding) (cdr keybinding))))
|
||||||
(add-hook 'prog-mode-hook 'turn-on-evil-mc-mode)
|
(add-hook 'prog-mode-hook 'turn-on-evil-mc-mode)
|
||||||
(add-hook 'text-mode-hook 'turn-on-evil-mc-mode))))
|
(add-hook 'text-mode-hook 'turn-on-evil-mc-mode))))
|
||||||
|
|
||||||
|
(defun multiple-cursors/init-multiple-cursors ()
|
||||||
|
(use-package multiple-cursors
|
||||||
|
:defer t
|
||||||
|
:init
|
||||||
|
(progn
|
||||||
|
(spacemacs/declare-prefix "sm" "multiple-cursors")
|
||||||
|
(spacemacs/declare-prefix "sms" "specials")
|
||||||
|
(spacemacs/set-leader-keys
|
||||||
|
"smm" 'mc/mark-more-like-this-extended
|
||||||
|
"smr" 'mc/edit-lines
|
||||||
|
"smb" 'mc/mark-all-like-this
|
||||||
|
"sma" 'mc/mark-all-dwim
|
||||||
|
"smss" 'mc/sort-regions
|
||||||
|
"smsr" 'set-rectangular-region-anchor
|
||||||
|
"smsm" 'mc/mark-sgml-tag-pair
|
||||||
|
"smsn" 'mc/insert-numbers
|
||||||
|
"smsl" 'mc/insert-letters
|
||||||
|
"smst" 'mc/reverse-regions)
|
||||||
|
(setq mc/always-run-for-all t)
|
||||||
|
(with-eval-after-load 'multiple-cursors-core
|
||||||
|
(add-to-list 'mc/cmds-to-run-once 'helm-M-x)
|
||||||
|
(add-to-list 'mc/cmds-to-run-once 'counsel-M-x)
|
||||||
|
(add-to-list 'mc/cmds-to-run-once 'spacemacs/default-pop-shell)
|
||||||
|
))))
|
||||||
|
|
Reference in a new issue