legacy-dotfiles/emacs/.emacs.d/site-lisp/evil-colemak.el
Tom Willemse db423b3ce2 Stop using colemak-evil
To become more familiar with the physical placement of evil's
keybindings I've written a new layout. This is basically the same as the
default except that it's mapped out over a colemak layout and hjkl has
become jkl; and ; has become h. I did this because I feel jkl; is more
comfortable.
2015-06-17 10:44:59 +02:00

222 lines
10 KiB
EmacsLisp

;;; evil-colemak.el --- My keybindings for Colemak -*- lexical-binding: t; -*-
;; Copyright (C) 2014 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Only the keybindings that are different from normal QWERTY bindings
;; are put in here.
;; Some of the code is copied from colemak-evil.
;;; Code:
(require 'evil)
(require 'undo-tree)
;; Remove all keybindings from the insert-state keymap.
(setcdr evil-insert-state-map nil)
;; ESC and C-g should switch back to normal state.
(define-key evil-insert-state-map (kbd "<escape>") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-normal-state-map (kbd "d") nil)
(define-key evil-normal-state-map (kbd "i") nil)
(define-key evil-normal-state-map (kbd "g") nil)
(define-key evil-normal-state-map (kbd "o") nil)
;;; Normal state
(define-key evil-normal-state-map "s" 'evil-delete)
(define-key evil-normal-state-map "S" 'evil-delete-line)
(define-key evil-normal-state-map "u" 'evil-insert)
(define-key evil-normal-state-map "U" 'evil-insert-line)
(define-key evil-normal-state-map "N" 'evil-join)
(define-key evil-normal-state-map "y" 'evil-open-below)
(define-key evil-normal-state-map "Y" 'evil-open-above)
(define-key evil-normal-state-map ";" 'evil-paste-after)
(define-key evil-normal-state-map ":" 'evil-paste-before)
(define-key evil-normal-state-map "p" 'evil-replace)
(define-key evil-normal-state-map "P" 'evil-replace-state)
(define-key evil-normal-state-map "r" 'evil-substitute)
(define-key evil-normal-state-map "R" 'evil-change-whole-line)
(define-key evil-normal-state-map "j" 'evil-yank)
(define-key evil-normal-state-map "J" 'evil-yank-line)
(define-key evil-normal-state-map "d&" 'evil-ex-repeat-global-substitute)
(define-key evil-normal-state-map "d8" 'what-cursor-position)
(define-key evil-normal-state-map "da" 'what-cursor-position)
(define-key evil-normal-state-map "du" 'evil-insert-resume)
(define-key evil-normal-state-map "dN" 'evil-join-whitespace)
(define-key evil-normal-state-map "dq" 'evil-fill-and-move)
(define-key evil-normal-state-map "dw" 'evil-fill)
(define-key evil-normal-state-map "dl" 'evil-downcase)
(define-key evil-normal-state-map "dL" 'evil-upcase)
(define-key evil-normal-state-map "dt" 'find-file-at-point)
(define-key evil-normal-state-map "dT" 'evil-find-file-at-point-with-line)
(define-key evil-normal-state-map "d?" 'evil-rot13)
(define-key evil-normal-state-map "d~" 'evil-invert-case)
(define-key evil-normal-state-map "zy" 'evil-open-fold)
(define-key evil-normal-state-map "zp" 'evil-open-folds)
(define-key evil-normal-state-map "\C-k" 'evil-paste-pop-next)
(define-key evil-normal-state-map (kbd "C-;") 'evil-paste-pop)
(define-key evil-normal-state-map "\C-g" 'pop-tag-mark)
;; go to last change
(define-key evil-normal-state-map "do" 'goto-last-change)
(define-key evil-normal-state-map "d," 'goto-last-change-reverse)
;; undo
(define-key evil-normal-state-map "l" 'undo)
(define-key evil-normal-state-map "\C-p" 'redo)
;; window commands
(define-key evil-window-map "e" 'evil-window-down)
(define-key evil-window-map "E" 'evil-window-move-very-bottom)
(define-key evil-window-map "i" 'evil-window-up)
(define-key evil-window-map "I" 'evil-window-move-very-top)
(define-key evil-window-map "o" 'evil-window-right)
(define-key evil-window-map "O" 'evil-window-move-far-right)
(define-key evil-window-map "k" 'evil-window-new)
(define-key evil-window-map "y" 'delete-other-windows)
(define-key evil-window-map ";" 'evil-window-mru)
(define-key evil-window-map "p" 'evil-window-rotate-downwards)
(define-key evil-window-map "P" 'evil-window-rotate-upwards)
(define-key evil-window-map "r" 'evil-window-split)
(define-key evil-window-map "R" 'evil-window-split)
(define-key evil-window-map "g" 'evil-window-top-left)
(define-key evil-window-map (kbd "C-S-n") 'evil-window-move-very-bottom)
(define-key evil-window-map "\C-n" 'evil-window-down)
(define-key evil-window-map (kbd "C-S-e") 'evil-window-move-very-top)
(define-key evil-window-map "\C-e" 'evil-window-up)
(define-key evil-window-map (kbd "C-S-i") 'evil-window-move-far-right)
(define-key evil-window-map "\C-i" 'evil-window-right)
(define-key evil-window-map "\C-k" 'evil-window-new)
(define-key evil-window-map "\C-y" 'delete-other-windows)
(define-key evil-window-map (kbd "C-;") 'evil-window-mru)
(define-key evil-window-map "\C-p" 'evil-window-rotate-downwards)
(define-key evil-window-map (kbd "C-S-p") 'evil-window-rotate-upwards)
(define-key evil-window-map "\C-r" 'evil-window-split)
(define-key evil-window-map (kbd "C-S-r") 'evil-window-split)
(define-key evil-window-map "\C-g" 'evil-window-top-left)
(define-key evil-window-map "\C-t" 'ffap-other-window)
;;; Motion state
;; "0" is a special command when called first
(define-key evil-motion-state-map "f" 'evil-forward-word-end)
(define-key evil-motion-state-map "F" 'evil-forward-WORD-end)
(define-key evil-motion-state-map "t" 'evil-find-char)
(define-key evil-motion-state-map "T" 'evil-find-char-backward)
(define-key evil-motion-state-map "D" 'evil-goto-line)
(define-key evil-motion-state-map "n" 'evil-backward-char)
(define-key evil-motion-state-map "e" 'evil-next-line)
(define-key evil-motion-state-map "i" 'evil-previous-line)
(define-key evil-motion-state-map "o" 'evil-forward-char)
(define-key evil-motion-state-map "E" 'evil-lookup)
(define-key evil-motion-state-map "I" 'evil-window-bottom)
(define-key evil-motion-state-map "k" 'evil-search-next)
(define-key evil-motion-state-map "K" 'evil-search-previous)
(define-key evil-motion-state-map "g" 'evil-find-char-to)
(define-key evil-motion-state-map "G" 'evil-find-char-to-backward)
(define-key evil-motion-state-map "ds" 'evil-goto-definition)
(define-key evil-motion-state-map "df" 'evil-backward-word-end)
(define-key evil-motion-state-map "dF" 'evil-backward-WORD-end)
(define-key evil-motion-state-map "dd" 'evil-goto-first-line)
(define-key evil-motion-state-map "dn" 'evil-next-visual-line)
(define-key evil-motion-state-map "de" 'evil-previous-visual-line)
(define-key evil-motion-state-map "d0" 'evil-beginning-of-visual-line)
(define-key evil-motion-state-map "d_" 'evil-last-non-blank)
(define-key evil-motion-state-map "d^" 'evil-first-non-blank-of-visual-line)
(define-key evil-motion-state-map "dm" 'evil-middle-of-visual-line)
(define-key evil-motion-state-map "d$" 'evil-end-of-visual-line)
(define-key evil-motion-state-map "d\C-]" 'find-tag)
(define-key evil-motion-state-map "d#" 'evil-search-unbounded-word-backward)
(define-key evil-motion-state-map "d*" 'evil-search-unbounded-word-forward)
(define-key evil-motion-state-map "h" 'evil-repeat-find-char)
(define-key evil-motion-state-map (kbd "C-t") 'evil-scroll-down)
(define-key evil-motion-state-map (kbd "C-f") 'evil-scroll-line-down)
(define-key evil-motion-state-map (kbd "C-t") 'evil-scroll-page-down)
(define-key evil-motion-state-map (kbd "C-y") 'evil-jump-backward)
(define-key evil-motion-state-map (kbd "C-j") 'evil-scroll-line-up)
;; (define-key evil-motion-state-map "zg" 'evil-scroll-line-to-top)
;; TODO: z RET has an advanced form taking an count before the RET
;; but this requires again a special state with a single command
;; bound to RET
;; (define-key evil-motion-state-map (vconcat "z" [return]) "zg^")
(define-key evil-motion-state-map "dv" 'evil-visual-restore)
;; (define-key evil-motion-state-map "zi" 'evil-scroll-column-right)
;; (define-key evil-motion-state-map [?z right] "zi")
;; (define-key evil-motion-state-map "zI" 'evil-scroll-right)
;; text objects
(define-key evil-outer-text-objects-map "r" 'evil-a-sentence)
(define-key evil-outer-text-objects-map ";" 'evil-a-paragraph)
(define-key evil-outer-text-objects-map "g" 'evil-a-tag)
(define-key evil-outer-text-objects-map "y" 'evil-a-symbol)
(define-key evil-inner-text-objects-map "r" 'evil-inner-sentence)
(define-key evil-inner-text-objects-map ";" 'evil-inner-paragraph)
(define-key evil-inner-text-objects-map "g" 'evil-inner-tag)
(define-key evil-inner-text-objects-map "y" 'evil-inner-symbol)
(define-key evil-motion-state-map "dk" 'evil-next-match)
(define-key evil-motion-state-map "dK" 'evil-previous-match)
(when evil-want-C-i-jump
(define-key evil-motion-state-map (kbd "C-u") 'evil-jump-forward))
(when evil-want-C-u-scroll
(define-key evil-motion-state-map (kbd "C-l") 'evil-scroll-up))
;;; Visual state
(define-key evil-visual-state-map "U" 'evil-insert)
(define-key evil-visual-state-map "y" 'exchange-point-and-mark)
(define-key evil-visual-state-map "Y" 'evil-visual-exchange-corners)
(define-key evil-visual-state-map "p" 'evil-change)
(define-key evil-visual-state-map "l" 'evil-downcase)
(define-key evil-visual-state-map "L" 'evil-upcase)
(define-key evil-visual-state-map "u" evil-inner-text-objects-map)
;;; Operator-Pending state
(define-key evil-operator-state-map "u" evil-inner-text-objects-map)
;; Ex
(define-key evil-motion-state-map "O" 'evil-ex)
;; search command line
(define-key evil-ex-search-keymap "\C-p" 'evil-paste-from-register)
;; ex command line
(define-key evil-ex-completion-map "\C-s" 'evil-ex-completion)
(define-key evil-ex-completion-map "\C-d" 'abort-recursive-edit)
(define-key evil-ex-completion-map "\C-e" 'evil-insert-digraph)
(define-key evil-ex-completion-map "\C-i" 'evil-ex-completion)
(define-key evil-ex-completion-map (kbd "C-;") #'next-complete-history-element)
(define-key evil-ex-completion-map "\C-p" 'evil-paste-from-register)
(define-key evil-ex-completion-map "\C-k" #'next-complete-history-element)
(define-key evil-ex-completion-map "\C-l" 'evil-delete-whole-line)
;; evil-read-key
(define-key evil-read-key-map (kbd "C-e") #'evil-read-digraph-char)
;;; Non-evil keymaps
;; (define-key undo-tree-map (kbd "l") 'undo-tree-undo)
(provide 'evil-colemak)
;;; evil-colemak.el ends here