You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Minimal steps to get Emacs with VIM emulation working.
Install Emacs.
Create the file ~/.emacs.d/init.el.
Paste the following in ~/.emacs.d/init.el.
;; This buffer is for text that is not saved, and for Lisp evaluation.;; To create a file, visit it with C-x C-f and enter text in its buffer.;; This is a import that ships with emacs.;; package is Emacs's package manager.
(require'package)
(setq package-check-signature nil)
;; Emacs has an official repository of packages and a more current;; unofficial one. Melpa is the 'unoffical one' (which in this;; case translates to more up to date, newer, and by extension,;; a bit more volatile). The official repo is called org. This;; repo is slow changing and extremely stable (but doesn't have;; all the cool/cutting edge packages that are being used).
(push '("melpa"."http://melpa.org/packages/") package-archives)
(push '("org"."http://orgmode.org/elpa/") package-archives)
(push '("melpa-stable"."https://stable.melpa.org/packages/") package-archives)
;; After the repositories have been set, initialize the package;; manager.
(package-initialize)
(defunamir-reinstall-packages-core ()
;; Emacs keeps a cache of the package list locally. We'll;; initialize this cache once. If you ever go to install a package;; and it cant be found, just rerun (package-reresh-contents).
(unless package-archive-contents (package-refresh-contents))
;; Here is our big bad package list. Whenever you want to;; install a new package, just add it to this list.
(setq bootstrap-list
'(use-package))
(dolist (package bootstrap-list)
(unless (package-installed-ppackage)
(package-installpackage))))
(defunamir-reinstall-packages ()
(interactive) (amir-reinstall-packages-core))
(amir-reinstall-packages-core)
(use-package evil
:ensuret:init
(setq evil-want-C-i-jump nil)
:config
(evil-mode 1)
;; wire up emacs so that I can spam the escape key and;; exit whatever ridiculous window/buffer it has me in.
(defunminibuffer-keyboard-quit ()
(interactive)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer"*Completions*") (delete-windows-on"*Completions*"))
(abort-recursive-edit)))
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
(global-set-key [escape] 'evil-exit-emacs-state)
;; In Tmux and iTerm, change the normal/edit mode cursors.
(defunevil-send-string-to-terminal (string)
(unless (display-graphic-p) (send-string-to-terminal string)))
(defunevil-terminal-cursor-change ()
(when (string= (getenv"TERM_PROGRAM") "iTerm.app")
(add-hook'evil-insert-state-entry-hook (lambda () (evil-send-string-to-terminal "\e]50;CursorShape=1\x7")))
(add-hook'evil-insert-state-exit-hook (lambda () (evil-send-string-to-terminal "\e]50;CursorShape=0\x7"))))
(when (and (getenv"TMUX") (string= (getenv"TERM_PROGRAM") "iTerm.app"))
(add-hook'evil-insert-state-entry-hook (lambda () (evil-send-string-to-terminal "\ePtmux;\e\e]50;CursorShape=1\x7\e\\")))
(add-hook'evil-insert-state-exit-hook (lambda () (evil-send-string-to-terminal "\ePtmux;\e\e]50;CursorShape=0\x7\e\\")))))
(evil-terminal-cursor-change))
Start up Emacs, it will probably give you an error.
Press Alt+x, type package-referesh-contents and press enter.
Exit Emacs by pressing Ctrl+x, Ctrl+c.
Re-open Emacs and you should have Vim mode enabled.