Willem Hoek

Using Emacs

Jan 05, 2020


The Great Wave off Kanagawa, Hokusai, 1829 - 1833


These notes / reminders are how I use Emacs. It is for my own usage but it might be useful to some of you.

Start Emacs in client/server mode

Emacs can run as a server (daemon) in the background, this speeds up startup time. If there isn’t an Emacs daemon running, it will start one and connect to it.

C:\emacs\bin\emacsclientw.exe -n -c -a ""

Org Mode

C-x n n     Narrow down MARKED AREA
C-x n d     Narrow down to the current NODE
C-x n w     Widen to entire buffer- CANCEL NARROW 

C-c C-e     Export
C-c .       Insert Date-time stamp
C-x r m     Set the bookmark for the visited file (once of)
C-x r l     Bookmark select

Key bindings

C-x RIGHT   Switch buffer
C-w         Cut (same as Ctrl-X in Windows)
M-w         Copy (same as Ctrl-C in Windows)
C-y         Paste (same as Ctrl-V in Windows)
C-k         Cut until end of line
C-x h       Select ALL
M-x write-region     Save selected text to a file

C-x c       Exit
C-x s       Save
C-x C-w     Save as another file

C-x o       Select OTHER window     (kbd "C-;")
C-x 0       Close THIS window
C-x 1       Close all but THIS ONE
C-x 2       Split HOR
C-x 3 	    Split VERT

C-x c-b     Buffer list, then d -> kill,  x -> execute)
C-x b       Buffer switch
C-x r-l     (lowercase "L")    Bookmark list

F3          Start recording macro
F4          Stop recording / Play
            
M-%         Search / replace - ! for all, y for next
M-s o       Show all

~/.emacs

(setq visible-bell t)
(setq ring-bell-function 'ignore)
(setq inhibit-startup-message t)
(setq inhibit-splash-screen t)

(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)

;; show the options holizontal. great for C-x b
(require 'ido)
(ido-mode t)

(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer-other-window)
(show-paren-mode 1)

(global-set-key (kbd "C-;") 'other-window) ;; same as C-x o
(global-set-key (kbd "C-c w") 'visual-line-mode)   ;; handy when working with text files

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(column-number-mode t)
 '(scroll-bar-mode nil)
 '(show-paren-mode t)
 '(size-indication-mode t)
 '(tool-bar-mode nil)
 '(tooltip-mode nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 102 :width normal)))))

References and further reading

[1] GNU Emacs website https://www.gnu.org/software/emacs/

[2] Using Emacs Series - videos and posts by Mike Zamansky. https://cestlaz.github.io/stories/emacs/

[3] Org Mode - https://orgmode.org/

Related Posts

Jane Street puzzle Feb 2021 SOLVED! OCaml to the rescue

Solving the Jane Street puzzle of Dec 2020 - Backtracking with OCaml

Automate your Jira reporting with Python and Excel

Solving the Jane Street Puzzle of June 2020; Circle Time

Solving the Jane Street Puzzle of May 2020; Expelled with OCaml

Never forget a birthday again with GitHub Actions and Python