Table of Contents

1 Package Loading

Usually in the beginning of a Emacs configuration files you add all of
the repositorys from where you will download all of your packages.

This at first installs the repository quelpa if not installed. Then
then it adds the repos melpa and marmalade.

(require 'package)

;; Install the package repo quelpa for a wider selection of packages
(unless (package-installed-p 'quelpa)
      (url-insert-file-contents "")

;; Adds melpa and marmalade package repos for a wider selection of packages
(add-to-list 'package-archives '("melpa" . ""))
(add-to-list 'package-archives '("marmalade" . ""))

;; Tries to install use-package if it is not already installed, in which case
;; it is enabled
(unless (package-installed-p 'use-package)
  (package-install 'use-package))

;; Initialize (and recognize) installed packages

2 Emacs 27 Tabs

In Emacs 27, the new feature of tabs (similar to those which are in a
web browser) came. The implementation is pretty good, with a global
tab-bar (under the menu-bar), in which each tab is bound to a set of
windows. In this way, it kind of works like a way of having workspaces
in Emacs.

To enable the tab bar the tab-bar-mode can be used. Here is a small
configuration which enables switching between tabs 1-8 with M-1
M-8 that is (alt-<tab number>). The variable
tab-bar-new-tab-choice is set to the default buffer which will be
enabled in a single window upon a new tab creation.

;; Enable tab-bar mode
(tab-bar-mode t)

;; Configure it with my preferences
(setq tab-bar-new-tab-choice "*scratch*"
      tab-bar-position t
      tab-bar-select-tab-modifiers '(alt meta)
      tab-bar-show t
      tab-bar-tab-hints t

;; Display the tabs as a name (active buffer) and the tab number
      tab-bar-tab-name-function 'tab-bar-tab-name-current-with-count)

;; My keybinding for creating a tab is C-c t (tab) n (new)  (C-c t n)
(global-set-key (kbd "C-c t n") 'tab-new)

;; My keybinding for closing the active tab is C-c t (tab) w (kill)  (C-c t w)
(global-set-key (kbd "C-c t w") 'tab-close)

;; Bind alt + 1-8 to switch to the respective tab
(global-set-key (kbd "M-1") '(lambda () (interactive) (tab-bar-select-tab 1)))
(global-set-key (kbd "M-2") '(lambda () (interactive) (tab-bar-select-tab 2)))
(global-set-key (kbd "M-3") '(lambda () (interactive) (tab-bar-select-tab 3)))
(global-set-key (kbd "M-4") '(lambda () (interactive) (tab-bar-select-tab 4)))
(global-set-key (kbd "M-5") '(lambda () (interactive) (tab-bar-select-tab 5)))
(global-set-key (kbd "M-6") '(lambda () (interactive) (tab-bar-select-tab 6)))
(global-set-key (kbd "M-7") '(lambda () (interactive) (tab-bar-select-tab 7)))
(global-set-key (kbd "M-8") '(lambda () (interactive) (tab-bar-select-tab 8)))


Emacs has a pretty solid bookmark system, of which i think has
keybindings by default. However i only use a small subset of the
bookmark features and have custom keybindings for it. It features
four main bookmark operations;

  1. New Bookmark (At current file/directory on cursor position)
  2. Edit Bookmark (Edit a bookmark, including removing a bookmark)
  3. Jump to bookmark (Goto a bookmark, being presented with a list of bookmarks)
  4. List Bookmarks (Get presented with a list of bookmarks, which one can select and jump to)

Bookmarks is a really powerful feature, which i would recommend. It
enables me to quickly go to places i often visit in an instant.

;; New bookmark C-c b (bookmark) n (new)
(global-set-key (kbd "C-c b n")
                '(lambda () (interactive)

;; List bookmarks C-c b (bookmark) l (list)
(global-set-key (kbd "C-c b l") 'list-bookmarks)

;; Edit bookmarks C-c b (bookmark) e (edit)
(global-set-key (kbd "C-c b e") 'edit-bookmarks)

;; List bookmarks C-c b (bookmark) j (jump)
(global-set-key (kbd "C-c b j") 'bookmark-jump)

4 YASnippet

YASnippet is a really useful package. The TLDR of YASnippet is that
you can create keywords, containing rules, such as positions. And have
text equal to the keyword insert text and activate those rules. This
disables the <tab> snippet expand, and enables yasnippet in

Where the following keybindings are defined;

  • C-c y n (Create a new snippet)
    Mnemonic: C-c [y]asnippet [n]ew
  • C-c y e (Expand a snippet)
    Mnemonic: C-c [y]asnippet [e]xpand
(use-package yasnippet :ensure t
  ;; You could globaly enable it
  ;; (yas-global-mode t)

  ;; This will bring up a new buffer for the creation of a new snippet
  (define-key yas-minor-mode-map (kbd "C-c y n") 'yas-new-snippet)
  ;; When the cursor is behind a key, this will activate the expansion
  (define-key yas-minor-mode-map (kbd "C-c y e") 'yas-expand)

  (setq yas/root-directory '("~/Repos/3macs/yasnippet/"))

  ;; Enable YAS in org mode
  (add-hook 'org-mode-hook        #'yas-minor-mode)
  ;; Enable YAS in elisp mode
  (add-hook 'emacs-lisp-mode-hook #'yas-minor-mode)
  (add-hook 'yas-minor-mode-hook
            '(lambda (&rest _)
               (local-unset-key (kbd "<tab>"))))                            
;; Contains a list of directories which to load snippets from

One can always just enable it globally and use tab completion with one
keybinding for creation.

(use-package yasnippet
  :ensure t
  (yas-global-mode t)
  (global-set-key (kbd "C-c y n") 'yas-new-snippet)
  (setq yas/root-directory '("~/Repos/3macs/yasnippet/")))

5 Formfeed-mode

formfeed-mode provides a visual horizontal bar to represent the
formfeed ascii character "^L" (in ASCII 0x0A) (In Emacs typing
"C-q C-l" will insert the form feed char. More information here.

The formfeed character used to be popular in sectioning code. And
since it can be used in almost every language without (usually) being
interpreted as code (i.e “like empty newlines”, ignored by
compiler). I find it extremely useful for structuring my code and

(use-package formfeed-mode 
  :ensure t
    (add-hook 'prog-mode-hook 'form-feed-mode)
    (add-hook 'text-mode-hook 'form-feed-mode))

or without use-package;

(require 'formfeed-mode)
(add-hook 'prog-mode-hook 'form-feed-mode)
(add-hook 'text-mode-hook 'form-feed-mode)