Skip to content

Prgebish/evim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Evil Visual Multi (evim)

https://melpa.org/packages/evim-badge.svg

Multiple cursors for evil-mode, inspired by vim-visual-multi.

demo/demo.gif

Features

  • Two modes: cursor mode (point cursors, operators need motions) and extend mode (selections, operators act directly)
  • Leader cursor with distinct highlighting
  • Per-cursor registers for yank/paste (1-to-1 distribution)
  • Evil movements, text objects, and operators at all cursors
  • evil-surround integration (S, ys, ds, cs)
  • Run normal commands, macros, or ex commands at all cursors
  • Restriction: limit search to a region
  • Undo/redo with automatic cursor resync
  • Theme-aware faces with auto-adaptation

Installation

MELPA (recommended)

(use-package evim
  :after evil
  :config
  (evim-setup-global-keys))

Doom Emacs

In packages.el:

(package! evim)

In config.el:

(use-package! evim
  :after evil
  :config
  (evim-setup-global-keys))

Then run doom sync and restart Emacs.

Doom may rebind some keys used by evim (e.g. C-n, C-Down, C-Up). If you encounter conflicts, override them in config.el:

;; Example: unbind C-n in Doom before evim takes over
(map! :n "C-n" nil)

Before the package is on MELPA, install directly from GitHub:

;; packages.el
(package! evim :recipe (:host github :repo "Prgebish/evim"))

Manual

Clone the repository, add it to load-path, and set up keys:

(add-to-list 'load-path "/path/to/evim")
(require 'evim)
(evim-setup-global-keys)

Quick Start

  1. Place cursor on a word, press C-n — the word is selected
  2. Press n to add the next match, q to skip, Q to remove
  3. Press Tab to switch between cursor/extend mode
  4. Edit at all cursors: c, d, i, a, r, etc.
  5. Press Esc to exit evim

Keybindings

The default leader key is \ (backslash). Customise with evim-leader-key.

Activation (evil normal/visual state)

KeyCommandDescription
C-nevim-find-wordSelect word under cursor, enter evim
C-Downevim-add-cursor-downAdd cursor on line below
C-Upevim-add-cursor-upAdd cursor on line above
s-mouse-1evim-add-cursor-at-clickAdd cursor at click position
\ g Sevim-reselect-lastReselect last evim session
\ cevim-visual-cursorsCreate cursors from visual selection (visual state)
\ revim-toggle-restrictSet restriction from visual selection (visual state)

General (active in both modes)

KeyCommandDescription
Escevim-exitExit evim
Tabevim-toggle-modeToggle cursor/extend mode
nevim-find-nextAdd next match
Nevim-find-prevAdd previous match
]evim-goto-nextMove leader to next cursor
[evim-goto-prevMove leader to previous cursor
qevim-skip-currentSkip leader, add next match
Qevim-remove-currentRemove leader cursor
C-nevim-add-next-matchAdd next pattern match
s-mouse-1evim-add-cursor-at-clickAdd cursor at click
Mevim-toggle-multilineToggle multiline search
"evil-use-registerSelect register for next yank/paste

Leader-prefixed (\ + key)

KeyCommandDescription
\ Aevim-select-allSelect all matches of current pattern
\ aevim-alignAlign cursors by inserting spaces
\ revim-toggle-restrictToggle search restriction
\ g Sevim-reselect-lastReselect last evim session
\ zevim-run-normalRun normal command at all cursors
\ @evim-run-macroRun macro from register at all cursors
\ :evim-run-exRun ex command at all cursor lines

Cursor Mode

Motions

KeyCommandDescription
h/j/k/levim-{backward,next,previous,forward}-*Basic movement
w/b/eevim-forward-word / backward-word / forward-word-endWord motions
0 / ^ / $evim-beginning-of-line / first-non-blank / end-of-lineLine motions
f/t/F/Tevim-find-char*Character search

Insert

KeyCommandDescription
ievim-insertInsert before cursor
aevim-appendInsert after cursor
Ievim-insert-lineInsert at line start
Aevim-append-lineInsert at line end
oevim-open-belowOpen line below
Oevim-open-aboveOpen line above

Operators (wait for motion/text object)

KeyCommandDescription
devim-operator-deleteDelete
cevim-operator-changeChange (delete + insert)
yevim-operator-yankYank
Devim-delete-to-eolDelete to end of line
Cevim-change-to-eolChange to end of line
Yevim-yank-lineYank whole line
>evim-operator-indentIndent (>>, >ip)
<evim-operator-outdentOutdent (<<, <ip)
guevim-operator-downcaseLowercase
gUevim-operator-upcaseUppercase
g~evim-operator-toggle-caseToggle case

Quick Edits

KeyCommandDescription
xevim-delete-charDelete char at cursor
Xevim-delete-char-backwardDelete char before cursor
revim-replace-charReplace char
~evim-toggle-case-charToggle case (1 char)
Jevim-join-linesJoin with next line
vevim-enter-extendEnter extend mode

Paste and Undo

KeyCommandDescription
pevim-paste-afterPaste after cursor
Pevim-paste-beforePaste before cursor
uevim-undoUndo
C-revim-redoRedo

Extend Mode

KeyCommandDescription
devim-deleteDelete selections
cevim-changeChange selections
sevim-changeChange selections (alias)
yevim-yankYank selections
pevim-paste-afterPaste (replaces selections)
Pevim-paste-beforePaste before selections
oevim-flip-directionFlip active end of selection
Uevim-upcaseUppercase selections
uevim-downcaseLowercase selections
~evim-toggle-caseToggle case of selections
Sevim-surroundSurround selections (evil-surround)
ievim-extend-inner-text-objectExtend to inner text object
aevim-extend-a-text-objectExtend to a text object

Surround (cursor mode, requires evil-surround)

Surround commands are accessed through the standard evil operators:

SequenceDescription
ys + motion + charAdd surround
ds + charDelete surround
cs + old + newChange surround

Configuration

All customizable variables with their defaults:

;; Leader key for prefix commands (\ A, \ a, \ r, \ z, \ @, \ :, \ g S)
;; Call (evim-rebind-leader) after changing to update keymaps.
;; Default: "\\"
(setq evim-leader-key "\\")

;; Color theme for cursor and region overlays.
;; Values: 'default, 'iceblue, 'ocean, 'neon, 'purplegray, 'nord,
;;         'codedark, 'spacegray, 'olive, 'sand, 'paper,
;;         'lightblue1, 'lightblue2, 'lightpurple1, 'lightpurple2
;; Dark themes:  iceblue, ocean, neon, purplegray, nord, codedark, spacegray, olive, sand
;; Light themes: lightblue1, lightblue2, lightpurple1, lightpurple2, paper, sand
;; Default: 'default
(setq evim-theme 'default)

;; How to highlight other pattern matches in the buffer.
;; Values: 'underline, 'background, nil (disable)
;; Default: 'underline
(setq evim-highlight-matches 'underline)

;; Show EVM[C 1/3] indicator in the mode-line.
;; Values: t, nil
;; Default: t
(setq evim-show-mode-line t)

Tutorial

The guide/ directory contains a hands-on tutorial in 5 parts:

  1. 01-cursors-and-navigation.txt — creating cursors and moving around
  2. 02-editing.txt — insert mode, operators, text objects, registers, surround
  3. 03-run-at-cursors.txt\ z, \ @, \ :
  4. 04-restrict.txt — limiting search to a region
  5. 05-undo-and-reselect.txt — undo, redo, reselect last session

Open any file in Emacs and follow the exercises directly in the buffer.

Acknowledgements

Inspired by vim-visual-multi by mg979.

Support

If you find evim useful, consider giving it a star — it helps others discover the project.

License

MIT

About

Multiple cursors for evil-mode, inspired by vim-visual-multi

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors