User Tools

Site Tools


Emacs Resources

Regular expressions

(“regexps,” “regexp,” “regex”)


Replace single spaces after end of sentence with two spaces in Emacs


Type the following:

[M-x] query-replace-regexp [RET]
\. \([A-Z]\) [RET]
.  \1 [RET]

Emacs replacement trick ADC used when writing SPM table report tool

(from here)

In output file (“” e.g.), AC used emacs regexp (regular expression) to reformat BA's, and just copied a rectangle to get region descriptions:

[M-x] replace-regexp [RET]
^.*Brodmann area.\([0-9]+\).* [RET]
BA\1 [RET]

Emacs regexp for removing newline characters from text copied from Adobe PDF file

[Originally from Anthony's science.txt file, entry dated 2015-09-03]

To remove all Windows newlines:

M-x replace-regexp 
C-q C-j RET

To add a newline before heading names, e.g. “I.” or “A.”

M-x replace-regexp 
.\. RET
C-q C-j \& RET

Add line break (RETURN) to end of all lines

[Put another way: insert spaces, insert empty line in between every line.]

M-x replace-regexp 

“\&” is the emacs pattern that stands for “the entire matched pattern”

C-q indicates something like “insert the following input literally” (I remember it by thinking of this as “quoting” something).

C-j inserts a line break (a RETURN keypress, but this might not be the most precise description).

resources/emacs_resources.txt · Last modified: 2019/05/22 16:08 (external edit)