Skip to content

Instantly share code, notes, and snippets.

@edmellum
Last active May 1, 2019 19:44
Show Gist options
  • Save edmellum/8560290 to your computer and use it in GitHub Desktop.
Save edmellum/8560290 to your computer and use it in GitHub Desktop.
Starter Emacs init.el for web developers. Save it in your .emacs.d directory, which should be in your home directory.
;; Don't need buttons in emacs! By running this early we avoid a flash
;; of buttons before they are removed.
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq use-dialog-box nil)
;; BORING: Ensure everything is UTF-8 all the time
(prefer-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8)
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(if (string-equal system-type "windows-nt")
(set-clipboard-coding-system 'utf-16le-dos)
(set-clipboard-coding-system 'utf-8))
;; Add the fantastic marmalade package repository to your lists to access hundreds of packages
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(dolist (source package-archives)
(add-to-list 'package-archives source t))
(package-initialize)
(package-refresh-contents)
;; Automatically install a bunch of useful packages. You should look read up about these.
(setq my-packages
'(
ido
json
magit
js2-mode
web-mode
undo-tree
expand-region
multiple-cursors
markdown-mode
color-theme-solarized
))
(dolist (package my-packages)
(unless (package-installed-p package)
(package-install package)))
;; Fire up the minor modes the theme we want going all the time everywhere
(load-theme 'solarized-light t)
(global-undo-tree-mode)
(ido-mode t)
;; Settings for ido. The most important one is fuzzy matching, like Sublime Text.
(setq
ido-case-fold t
ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point nil
ido-max-prospects 10
yas/prompt-functions '(yas/ido-prompt)
)
;; Some keybindings for the extra packages and improved built-ins
(global-set-key (kbd "C-=") 'er/expand-region)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
;; This one is kind of big, it reindents when hitting return. Something you usually need to do manually.
(global-set-key (kbd "RET") 'reindent-then-newline-and-indent)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key "\M-s" 'other-window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment