+ (mapc (lambda (map)
+ (define-key map "\C-W s" 'evil-window-split)
+ (define-key map "\C-W v" 'evil-window-vsplit)
+ (define-key map "\C-h" 'evil-window-left)
+ (define-key map "\C-j" 'evil-window-down)
+ (define-key map "\C-k" 'evil-window-up)
+ (define-key map "\C-l" 'evil-window-right)
+ (define-key map (kbd "C->") (lambda () (interactive) (evil-window-increase-width 3)))
+ (define-key map (kbd "C-<") (lambda () (interactive) (evil-window-decrease-width 3)))
+ (define-key map (kbd "C-+") (lambda () (interactive) (evil-window-increase-height 3)))
+ (define-key map (kbd "C--") (lambda () (interactive) (evil-window-decrease-height 3)))
+ (define-key map (kbd "C-=") (lambda () (interactive) (balance-windows))))
+ (list evil-normal-state-map evil-motion-state-map)))
+#+END_SRC
+
+** Initial mode and state config
+- Use =normal= as the default state but exclude some special modes.
+- Bind =[escape]= to =normal= mode. This only works on GUI Emacs. If need to work on Terminal, shoudl also bind =(kbd
+ "<ESC>)=, but this will make the combined key =M-= not wor.
+- Not alias =insert= state to =emacs= state, as it break some vi's feature in insert mode, such as column edit. Instead,
+ here add a advice function to change the sate as emacs when enter insert mode, but this is only limited in some
+ certain modes.
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (defvar my-mode-list-to-use-emacs-as-insert '(emacs-lisp-mode org-mode eshell-mode lisp-interaction-mode)
+ "The mode in this list will consider insert state as emacs state by adding `advice-add' below.")
+
+ (defvar my-modes-use-emacs-init '(emacs-lisp-mode org-mode lisp-interaction-mode eshell-mode text-mode)
+ "The mode in this list will use emacs sate as a initial evil state.")
+
+ (with-eval-after-load "evil"
+ (setq evil-default-state 'normal)
+ ;; (defalias 'evil-inset-mode 'evil-emacs-state)