
Emacs is the most powerful text editor.
It is so powerful that you cannot limit it to this task alone; removing "text" in the above statement gives a better idea of what Emacs is.
It is one of the big marvels of computer codes, along with Unix, $\mathrm{\TeX}$ and others. Stallman wrote the popular GNU version in 1984 and it is still actively maintained as of today and will hopefully remain so forever. This is the real jewel.
The XEmacs branch, from the flamboyant Jamie Zawinski, was one of the earliest forking process in the computer software industry. It's without any doubt the version to use in the DNA lounge.
To align a full block, select and Tab.
To remove trailing␣␣␣␣␣␣spaces, use M-SPACE. This is however preempted by kde for "Run command", for which I prefer the global alternative Alt+F2, so just remove this assignment in ksettings.
To replace a character, say ";", with a line-break, use [2]:
M-x replace-string RET ; RET C-q C-j
with C-q for "quoted-insert" and C-j for "newline".
To swap two contiguous lines, use C-x C-t on the 2nd line (after binding transpose-lines to it [3]).
See [4]
C-x r s a | store region as “a”
C-x r i a | insert region stored in “a”
C-x r r a | store rectangle as “a”
C-x r SPC a | store current point as “a”
C-x r j a | move to point in “a”
C-x r w a | store configuration of windows in frame
C-x r j a | restore window configurations
C-x r f a | store window configuration for all frames
C-x r j a | restore all window configurations
C-x r N | insert a column of successive numbers - Prefix with C-u to set starting value.
C-u 1 C-x r n a | store 1 in “a”
C-u 1 C-x r + a | add 1 to number in “a”
C-x r i a | insert number in “a”
C-x r m RET | save default
C-x r m <NAME> RET | save as NAME
C-x r b RET move to | default
C-x r b <NAME> RET | move to NAME
C-x r l list
This is like registers but on steroids: there, you record entire sequences.
See the documentation or follow these steps:
This is for instance how to bind subequations and align with automatic labelling (after my uniqname convention) for aucTeX:
(fset 'mysubeqs
[?\C-c ?\C-e ?s ?u ?b ?e ?q ?u ?a ?t ?i ?o ?n ?s return ?\\ ?l ?a ?b ?e ?l ?\{ ?e ?q ?: ?\C-u ?\M-! ?u ?n ?i ?q ?n ?a ?m ?e return ?\C-e ?\} return ?\C-c ?\C-e ?a ?l ?i ?g ?n return return])
(global-set-key (kbd "C-c s") 'mysubeqs)
To define a new Lisp command M-x eval-region RET on the code itself of M-x Eval-buffer to evaluate the whole page.
A file can specify local variables. "Visiting" the file checks for local variable and makes them local to the buffer. We use this mainly for aucTeX, to read:
%%% Local Variables: %%% mode: latex %%% TeX-master: t %%% TeX-command-extra-options: "-shell-escape" %%% End:
the -shell-escape command is useful when compiling, e.g., with minted (and is usually not needed).
If for some reason, pdf stops compiling (and reverts to dvi) or there is a complain of no-matching-viewer, then:
M-x TeX-PDF-mode
should revert to enabling it.
A proofread .tex comes back with three kinds of mark: \sout{...} around what should go, \textcolor{red}{...} around what should come in, and \textcolor{blue}{[Note: ...]} for a comment to be resolved and then deleted. proof.el settles them one at a time, or all at once, matching braces instead of trusting a regexp, so nested braces, \cite, maths and multi-line arguments all survive—the reasoning is in the hack that started it.
The file lives in ~/comp/emacs/lisp/proof.el and is autoloaded from .emacs (v°1.9), so the commands are there in every .tex buffer with nothing to load by hand:
| Keys | Command | What it does |
|---|---|---|
| C-c p a or Ctrl+◯ | proof-accept-at-point | accept the innermost mark at point, or every mark the selection touches: the struck text goes, the red text stays, the blue note goes |
| C-c p r or Ctrl+✕ | proof-reject-at-point | reject it: the struck text comes back, the red text goes, the blue note goes as well |
| C-c p A | proof-accept-all | accept every mark in the buffer; with C-u first, ask at each one |
◯ and ✕ are the round keys of the gaming keyboard, whose bare presses belong to xbindkeys—the AF tag and tex2uni—but whose Ctrl versions fall through to Emacs untouched, so a proofing pass is one key for yes and one key for no. C-c p is the typed equivalent, and the only free prefix left: C-c C-p belongs to preview-latex, C-c C-a runs the whole compile chain, and my own C-c letters were taken.
A mark only partly inside the selection is split, the rest staying marked. A selection boundary falling inside a brace group is refused rather than left unbalanced. A \cite inside a strike-out has to be written \mbox{\cite{...}}, as ulem and natbib otherwise fail at a page break; the \mbox comes off when the struck text is restored.
My dot-emacs configuration file: .emacs.gz. It can be kept compressed as ".emacs.gz" in the home directory /home/laussy/ and opened directly with emacs and saved as such.
Versions:
My Emacs-abbrevs file.