Skip to content

Leader keys

Evil supports a simple implementation of Vim’s `leader' keys. To bind a function to a leader key you can use the expression <leader> in a key mapping, e.g.

emacs-lisp
(evil-define-key 'normal 'global (kbd "<leader>fs") 'save-buffer)

Likewise, you can use the expression <localleader> to mimic Vim’s local leader, which is designed for mode-specific key bindings.

You can use the function evil-set-leader to designate which key acts as the leader and the local leader.

Emacs Lisp Autofunction: (evil-set-leader STATE KEY [LOCALLEADER])

Set `KEY' to trigger leader bindings in `STATE'. `KEY' should be in the form produced by kbd. `STATE' is one of normal, insert, visual, replace, operator, motion, emacs, a list of one or more of these, or nil, which means all of the above. If `LOCALLEADER' is non-nil, set the local leader instead.