This page last modified: Sep 15 2005
Align lines by an arbitrary regexp. For emacs regexp docs see: https://www.cs.elte.hu/local/texinfo/emacs/emacs_16.html#SEC85 Emacs regexps are quite different from Perl regexps. Many of the \x constructs exist in both, but have totally different meanings. Oddly, isearch-forward-regexp seems to interpret regexps differently than query-replace-regexp. The isearch variant seems to be greedy, whereas the default elsewhere is non-greedy matching. There doesn't seem to be an override for the non-greedy, although in many cases there will be workarounds. To align region and simultaneously set the aligning regexp use: align-regexp Align a new region with the existing align-regexp: align-entire Un-align by doing a query-replace-regexp with a string. For example replace "\s += " with " = ". Emacs doesn't seem to understand octal e.g. \040 is space. Enter chars with ^q and the character you need. There are syntax classes, used with \s whitespace \s \s- word \sw symbol \s_ punctuation \, parenthesis \s( \s) (may match {} [] {}) quote \s" escape \s\ character quote \s/ comment start \s< comment end \s> generic comment delimiter \s! generic string delimiter \s| Use registers instead of a clipboard Regitsters are named with a single character. Letters work, and apparently do carriage return, etc. copy region to register a C-x r x a Instert register a C-x r i a You can use the registers numerically i.e. for a counter in a keyboard macro. Position the cursor on a number. Copy the number into register a C-x r n a Increment the number in register a C-x r + a C-x r + increment-register C-x r n number-to-register C-x r g insert-register C-x r i insert-register C-x r x copy-to-register C-x r s copy-to-register Indent values aligned like this: $cspecies{"ARABIDOPSIS"} = 6; $cspecies{"DROSOPHILA"} = 44; $cspecies{"E_COLI"} = 4; Assuming all the values are in the column right after the equal sign and you want to indent to column 34. search "=" esc-X indent-to-column 34 control-N control-A