Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
291 lines (239 sloc) 8.39 KB

General configuration

These are my settings that are called in dotspacemacs/user-config. This function is called at the very end of Spacemacs initialization after layers configuration.


Hitting TAB always just indents the current line.

(setq tab-always-indent t)

Only one auth source for magit & co.

(setq auth-sources '("~/.netrc"))


(prefer-coding-system 'utf-8)

Enable line wrapping

(setq truncate-lines nil)


Clean up spaceline contents.

(with-eval-after-load 'spaceline-segments

Major Mode Settings


Don’t automatically insert the magic encoding comment.

(setq ruby-insert-encoding-magic-comment nil)

Keybinding to toggle between new and old hash syntax.

  "xrh" 'ruby-toggle-hash-syntax)

Underscore should be a word delimiter in slim.

(add-hook 'slim-mode-hook #'(lambda () (modify-syntax-entry ?_ "_")))


Better formatting for test output buffers.

(setq alchemist-test-truncate-lines nil)

Call elixir-format before save.

(add-hook 'elixir-mode-hook
          (lambda () (add-hook 'before-save-hook 'elixir-format nil t)))


Set tab width to 4.

(setq-default tab-width 4)

Call go-format before save.

(setq go-format-before-save t)

Enable flycheck for Go mode.

(add-hook 'go-mode-hook
          (lambda () (flycheck-mode 1)))

Web Mode

Intendation settings

(setq web-mode-css-indent-offset 2)
(setq js2-basic-offset 2)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq css-indent-offset 2)
(setq-default js2-basic-offset 2
              js-indent-level 2)


Allow .dir-locals.el files to set prettier-related settings.

(put 'prettier-js-args 'safe-local-variable 'listp)
(put 'prettier-js-command 'safe-local-variable 'stringp)

Setup nodejs-repl.el keybindings.

(spacemacs/set-leader-keys-for-major-mode 'js2-mode "ne" 'nodejs-repl-send-last-expression)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "nl" 'nodejs-repl-send-line)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "nr" 'nodejs-repl-send-region)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "nb" 'nodejs-repl-send-buffer)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "nf" 'nodejs-repl-load-file)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "n'" 'nodejs-repl-switch-to-repl)
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "ns" 'nodejs-repl-switch-to-repl)


The sqlfmt does not work very well with Postgres and is also outdated. This uses pgFormatter instead, installed with brew install pgformatter.

(setq sqlfmt-executable "pg_format")
(setq sqlfmt-options '())



Make evil-mode up/down operate in screen lines instead of logical lines.

(define-key evil-motion-state-map "j" 'evil-next-visual-line)
(define-key evil-motion-state-map "k" 'evil-previous-visual-line)

Also in visual mode…

(define-key evil-visual-state-map "j" 'evil-next-visual-line)
(define-key evil-visual-state-map "k" 'evil-previous-visual-line)

Move line under cursor with C-j/k.

(define-key evil-normal-state-map (kbd "C-j") 'move-text-down)
(define-key evil-normal-state-map (kbd "C-k") 'move-text-up)

Pressing H in any edit mode moves the cursor to the first non-blank character.

(evil-global-set-key 'normal "H" 'evil-first-non-blank)
(evil-global-set-key 'visual "H" 'evil-first-non-blank)
(evil-global-set-key 'motion "H" 'evil-first-non-blank)

Pressing L in any edit mode moves the cursor to the end of line.

(evil-global-set-key 'normal "L" (lambda () (interactive) (evil-end-of-line)))
(evil-global-set-key 'visual "L" (lambda () (interactive) (evil-end-of-line)))
(evil-global-set-key 'motion "L" (lambda () (interactive) (evil-end-of-line)))

Type g l to get a fast home row friendly jump menu to go to a visible line.

(define-key evil-motion-state-map "gl" 'evil-avy-goto-line)
(define-key evil-normal-state-map "gl" 'evil-avy-goto-line)

Type g o <char> <char> to get a fast home row friendly jump menu to go to a visible word that starts with these characters.

(define-key evil-motion-state-map "go" 'evil-avy-goto-char-2)
(define-key evil-normal-state-map "go" 'evil-avy-goto-char-2)


Type Q to execute the macro recorded to q.

(evil-global-set-key 'normal (kbd "Q") (lambda () (interactive) (evil-execute-macro 1 "@q")))


In dired, move to parent directory with h and open thing under cursor with l.

(with-eval-after-load 'dired
  (evil-define-key 'normal dired-mode-map
    "h" 'dired-up-directory
    "l" 'dired-find-file


Make Umlauts work like in the rest of MacOS.

(global-unset-key (kbd "M-s"))
(global-set-key (kbd "M-s")
                (lambda ()
                  "Insert ß."
                  (insert "ß")))
(global-unset-key (kbd "M-u"))
(global-set-key (kbd "M-u a")
                (lambda ()
                  "Insert ä."
                  (insert "ä")))
(global-set-key (kbd "M-u A")
                (lambda ()
                  "Insert Ä."
                  (insert "Ä")))
(global-set-key (kbd "M-u o")
                (lambda ()
                  "Insert ö."
                  (insert "ö")))
(global-set-key (kbd "M-u O")
                (lambda ()
                  "Insert Ö."
                  (insert "Ö")))
(global-set-key (kbd "M-u u")
                (lambda ()
                  "Insert ü."
                  (insert "ü")))
(global-set-key (kbd "M-u U")
                (lambda ()
                  "Insert Ü."
                  (insert "Ü")))


Set hippie expand from M-/ to ctrl-space.

(global-set-key (kbd "C-SPC") 'hippie-expand)


Overwrite emoji settings.

(defun --set-emoji-font (frame)
  "Adjust the font settings of FRAME so Emacs can display emoji properly."
  (if (eq system-type 'darwin)
      ;; For NS/Cocoa
      (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji" :size 10) frame 'prepend)
    ;; For Linux
    (set-fontset-font t 'symbol (font-spec :family "Symbola") frame 'prepend)))

;; For when Emacs is started in GUI mode:
(--set-emoji-font nil)
;; Hook for when a frame is created with emacsclient
;; see
(add-hook 'after-make-frame-functions '--set-emoji-font)
(setq company-emoji-insert-unicode t)

Custom Functions

Helper functions that I call directly with SPC SPC.

Switch between Rails i18n files

This function switches between the German and the English translation file in a Rails project. Especially handy, if the project has a lot of files per language.

(defun switch-rails-i18n-file()
  "Switches to the i18n file in the other language"
  (if (search "/de/" buffer-file-name)
    (find-file (replace-regexp-in-string "/de/" "/en/" (buffer-file-name)))
    (find-file (replace-regexp-in-string "/en/" "/de/" (buffer-file-name))))


In the end, satisfy the Spacemacs loading mechanism.

(provide 'my-general-config)
You can’t perform that action at this time.