m (→Keyboard macros) |
m (→Useful) |
||
Line 21: | Line 21: | ||
with C-q for "quoted-insert" and C-j for "newline". | with C-q for "quoted-insert" and C-j for "newline". | ||
+ | |||
+ | To swap two contiguous lines, use <tt>C-x C-t</tt> on the 2nd line (after binding <tt>transpose-lines</tt> to it [https://stackoverflow.com/a/2423919/15255893]). | ||
=== Registers === | === Registers === |
Contents |
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 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 [1]:
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 [2]).
See [3]
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.
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.