Best features for text-editing in emacs
Table of Contents
There has been recent discussion about emacs for text editing and it got me thinking; I use emacs for a lot of non-code text editing and here are some features I use all the time that lead me to consider emacs good at text-editing. I’ll separate them into built-in and external library categories. What would you add to this list for things that help with raw text-editing (not IDE-like programming features)?
Text Editing features
Built In
besides the regular cursor navigation stuff (I make heavy use of C-a
, C-e
, M-f
, M-b
, M-e
, M-S->
, M-S-<
, C-k
)
- Undo; not special, but something that is a must-have at easy key-distance. I’ve bound it to
C-/
and reach for the command instinctively all the time. Likewise,C-l
(recenter-top-bottom
)as the non-destructive command that will reset undo (allowing me to re-do). ALL. THE. TIME. - buffer splitting and multiple views. Not to be forgotten; I am constantly using multiple buffers, both in the same file and in different ones, and my muscle-memory knows
C-x 2
andC-x 3
and closing them withC-x 0
orC-x 1
. C-t
transpose-chars
and its companionM-t
transpose wordC-x i
(insert-file)
to stick stuff straight into my documentM-q
(fill-paragraph)
since my “paragraphs” have unlimited line length, this removes line breaksM-/
(dabbrev-expand)
which replaces the word at point with the nearest thing in some open buffer. Repeating it cycles through replacement options. Great as a super-quick spell-check or completion when you’ve just started some annoyingly long word. Great for code variables as well as natural language prefixes.ispell
and its family for spell-checking, which can be super-powered by extra libs- Multiple kill-ring, meaning you can copy three chunks of text from somewhere and paste them in the places you want, instead of having to go back to copy the second, then paste, then third, then paste, you’ve got it all in one go. I frequently wish for a kill ring when I’m in my browser or libre calc.
replace-regexp
which, along with plain old regexp replacement, lets you replace with the results of a function. I’ve used this to implement transliterations, to fix mis-sectioned documents when line-breaks were mistaken for new sections, etc.- word casing with
M-l
downcase-dwim
,M-c
capitalize-dwim
, andM-u
upcase-dwim
- Registers, which can contain points, words, or other things that you might want to paste in at some unknown time in the future, some undefined number of times
follow-mode
so that in two columns I can span twice the vertical length and paging up/down one moves the other to stay in line.clone-indirect-buffer
makes a copy of a section of a buffer which can take buffer-state changes that won’t effect the whole buffer (e.g. text-size, collapsed content, highlights) without effecting the main buffer view, while content changes will be visible in both places.- Indentation-control. Select some lines, then do
C-x TAB
(indent-rigidly
)and press left/right until your spacing is what you want. just-one-space
, included in simple.el with emacs: press once to remove all but one space at cursor spot; twice two remove all at once, three times to start over.
Library functions
- Upgraded spell-check with flyspell-correct https://github.com/d12frosted/flyspell-correct
- Super-fast cutting with ace-jump-zap https://github.com/waymondo/ace-jump-zap
- One-button hop-arounds and Char nav. https://github.com/tam17aki/ace-isearch
- anzu-mode for incremental query-replace. https://github.com/emacsorphanage/anzu
- Kill-ring helpers are plenty; there are helm versions, ivy versions, etc; currently I use
consult-yank-pop
. I bind these toM-y
to replace regular yank-pop so I can actually view my yank options. - multiple cursors https://github.com/magnars/multiple-cursors.el . Most useful when editing structured text, but the possibilities are great.
- flyspell-correct for a better spell-checking experience https://github.com/d12frosted/flyspell-correct
- yasnippet for potentially complex snippet expansion in any mode https://github.com/joaotavora/yasnippet
- ace-jump for jumping to lines on screen https://github.com/winterTTr/ace-jump-mode
- yasnippet for smart snippet insertion you can easily customize https://github.com/joaotavora/yasnippet
Notable Mention
The emacs reddit community had some excellent recommendations, some of which I haven’t tried
- https://github.com/mkhl/drag-stuff for moving and copying chunks of text
- built-in Macros for automating input
- built-in Rectangle manipulation
Resources
- reddit on this: https://www.reddit.com/r/emacs/comments/ld9j5k/best_features_for_textediting_in_emacs/
- 30 years of experience writes in 2020 about “finding” emacs. “Why I chose Emacs as my new text editor” https://takeonrules.com/2020/10/18/why-i-chose-emacs-as-my-new-text-editor/
- “Why Emacs is a great text editor” https://www.badykov.com/emacs/2018/07/31/why-emacs-is-a-great-editor/
- Reddit related question, “How good is Emac’s text editing?” https://www.reddit.com/r/emacs/comments/lapmis/how_good_is_emacs_text_editing/