Spacemacs Rocks Note Day 7
A series of notes that I learn Emacs hacking. Introduction to evil-mode, packages to augment evil, such as evil-leader, eveil-surrond, evil-nerd-commenter, powerline-evil; misc. improvement, such as window-numbering, which-key and powerline packages.
Use Evil to enable
- aka “Extensible vi layer for Emacs”.
- In the
init-packages.el, add the configuration below
(setcdr evil-insert-state-map nil)
(define-key evil-insert-state-map [escape] 'evil-normal-state)
- Some difference between
C-d to page down, but
C-u does not page up. Because
C-u is used as “Universal args” in Emacs. We can change this in
- PDF manual for user switching from vim to Emacs. Evil.pdf.
- Evil state = Emacs mode
- evil normal state
- evail insert state
- evil visual state
- evil motion state
- evil emacs state
- evil operator state (diw)
We want to set the evil state when we enter certain mode, use the following code
(dolist (mode '(ag-mode
(add-to-list 'evil-emacs-state-mode mode))
- Enable key binding in certain mode
(add-hook 'occur-mode-hook (lambda ()
(evil-add-hjkl-bindings occur-mode-map 'emacs
(kbd "/") 'evil-search-forward
(kbd "n") 'evil-search-next
(kbd "N") 'evil-search-previous
(kbd "C-d") 'evil-scroll-down
(kbd "C-u") 'evil-scroll-up
- Add more plugins to customize
(define-key evil-normal-state-map (kbd ",/") 'evilnc-comment-or-uncomment-lines)
(define-key evil-visual-state-map (kbd ",/") 'evilnc-comment-or-uncomment-lines)
powerline-evil package. A powerline minor mode for the evil mode. Try to add window number to the powerline, but failed. In the video, window numbering is finally enabled without loading the powerline.
C-w to delete a word backward
(global-set-key (kbd "C-w") 'backward-kill-word)
- Polish the mode line, make it special and beautiful.
- Set popup window properties
(setq which-key-side-window-max-height 0.25)
(setq which-key-side-window-location 'right)
Search in org agenda
C-a enter agenda mode.
s to search.
- Read the key in list for details.