Miscellaneous Emacs
Here are some really nice, low-maintenance tweaks that can make your Emacs extra shiny.
rainbow
The rainbow-mode
package displays color strings in that color; e.g. #000000
would be
displayed as white in the buffer. This is really handy for web UI work
or other places where you deal with color strings a lot. You can
activate this in a buffer with M-x rainbow-mode RET
, or add it as a
mode hook. Here's an example of adding it to go-mode
:
(add-hook 'go-mode-hook 'rainbow-mode)
A related package is rainbow-delimiters
, which colors matching
delimiters like parentheses to make it easier to decide what goes with
what.
hideshow
Hideshow offers code folding in Emacs for things like functions and
classes. This can be useful when dealing with large classes or long
methods. You can get visual fold fringes with
hideshowvis. I bind hideshow
commands to C-TAB
for folding and C-S-TAB
for unfolding like this:
;; Keybindings to hide/show text with hideshow
(global-set-key [C-tab] 'hs-hide-block)
(global-set-key [C-S-iso-lefttab] 'hs-show-block)
diff-hl
The diff-hl package highlights
Git status in the side ribbon. This can show unstaged and uncommitted
deletions and insertions, so you can have a sense of the file's status
without having to do a manual git diff <file>
. Here is an example of
associating diff-hl
with Python mode:
(add-hook 'python-mode-hook 'diff-hl)
Hiding the toolbar
;; No toolbar
(tool-bar-mode -1)
Automatching parentheses and quotes
Note
This feature can be annoying when writing one-off commands in the
interactiv eval buffer entered with M-;
, YMMV.
;; Electric pair mode (automatch parens and quotes)
(electric-pair-mode 1)
Line/column numbering, and current row highlighting
;; Line/column numbering
(global-linum-mode 1)
(column-number-mode)
(global-hl-line-mode t)
Beacon mode
A strobe marking your cursor location when you perform a large jump and might lost sight of where it is.
(beacon-mode)
Doom modeline
Very nice modelines, with Git branch and file encoding information.
(doom-modeline-mode)