This second demonstration of emacs accompanies http://pages.stat.wisc.edu/~jgillett/DSCP/emacs/emacs.html. It covers the more advanced lines that are crossed out. ---------------------------------------------------------------------- Practice with emacs: - Clean up from first demo by deleting all downloaded files: - open ~/emacs directory: C-x C-f ~/e TAB Enter - mark all files for deleting (one d per file line): d d d d - expunge marked files: x y - Use wget download data.txt and tiny.R into ~/emacs again (to restore them) - Cursor Motion - open ~/emacs/data.txt: C-x C-f ~/e TAB d TAB Enter - jump to start and end of line (twice): C-a C-e C-a C-e - jump to start and end of buffer (twice): M-< M-> M-< M-> (note that Shift is required to type < or >) - Cut, Copy, Paste - jump to start: M-< - kill (kill, undo, next) all four rows, one at a time: C-k C-/ C-n C-k C-/ C-n C-k C-/ C-n C-k C-/ C-n - add blank line: Enter - yank; then replace last yank with previous kill (3 times): C-y M-y M-y M-y - clean up yank via jump to start of line, kill: C-a C-k - use "yank; replace last yank with previous kill" to write four lines reversed: C-y M-y Enter C-y M-y Enter C-y M-y Enter C-y M-y Enter - M-x revert-buffer Enter y - use "kill, yank rectangle region" to move 2nd (ID) column left: - set mark at top left of 2nd column: C-s 1 C-b C-SPACE - move to "j" past bottom right of 2nd column: C-s jj C-b C-b - kill rectangle region: C-x r k - jump to start of buffer: M-< - yank rectangle region: C-x r y - undo twice: C-/ C-/ - Error Recovery - restore buffer to original contents: M-x revert-buffer Enter y - Multiple Windows - split window vertically: C-x 2 - switch to other window (twice): C-x o C-x o - open tiny.R: C-x C-f t TAB Enter - copy first line of data.txt into bottom of tiny.R: C-x o C-k C-/ C-x o M-> C-y - make one window: C-x 1 - split window horizontally: C-x 3 - make one window: C-x 1 - go nuts: C-x 2 C-x 3 M-< C-x o M-> C-x o C-x C-f data.txt Enter - recover: C-x 1 - Incremental Search - regexp search forward, regexp search backward: see http://pages.stat.wisc.edu/~jgillett/DSCP/emacs/regularExpressions.pdf - find all occurences of "123" in data.txt: C-x C-f d TAB Enter M-x occur Enter 123 Enter - Query Replace - interactively replace regexp: see regularExpressions.pdf - Regular Expressions for search and query replace: see regularExpressions.pdf - R - find tiny.R: C-x C-f t TAB Enter - indent buffer: M-< (jump to top), C-SPACE (set mark), M-> (jump to bottom), M-x indent-region Enter - split window vertically, switch to other: C-x 2 C-x o - start R buffer: M-x R Enter Enter C-x o - run one line of R code (5 times): C-c C-n C-c C-n C-c C-n C-c C-n C-c C-n - jump to start of buffer: M-< - run chunk of R code (3 times): C-c C-c C-c C-c C-c C-c - run buffer of R code: C-c C-b - show documentation for R mode (ESS): M-x help Enter m - Help - show function a key runs (e.g. what does C-w do?): M-x help Enter k C-w