This first demonstration of emacs accompanies http://pages.stat.wisc.edu/~jgillett/DSCP/emacs/emacs.html. It covers the lines that are not crossed out. (I wrote this file in response to student requests, but I do not really intend that students would read it, as any little mistake makes it impossible to follow. Instead, practice with the various emacs commands, possibly guided a little by this file.) ---------------------------------------------------------------------- Make emacs folder: - cd # change to home directory - mkdir emacs # create new directory "emacs" - cd emacs # change to emacs diretory Save data.txt to emacs folder: - Run wget https://pages.stat.wisc.edu/~jgillett/DSCP/emacs/data.txt Practice with emacs: - Start/Stop - start emacs: - login to public02, public03, or public04 (i.e. public02.stat.wisc.edu, etc.) - emacs -nw ("-nw" = "--no-window-system": run emacs in Terminal window) - exit: C-x C-c - Files - read a file into emacs: C-x C-f ~/emacs/data.txt Enter ("~" = "home directory") It's easier to use TAB to complete names: C-x C-f ~/e TAB TAB Enter - create a new file: C-x C-f junk.txt Enter - insert a file: C-x i d TAB Enter - save: C-x C-s - save as: C-x C-w junk2.txt (sanity check: use GUI to view emacs folder) - Cursor Motion - forward, next, backward, previous (3 times each): C-f C-f C-f C-n C-n C-n C-b C-b C-b C-p C-p C-p - Cut, Copy, Paste - delete current character (after moving forward 2): C-f C-f C-d - delete previous character: Backspace - kill to end of line (do it a second time to get newline): C-k C-k - set mark; "region" is between invisible "mark" and "point" (cursor) (after 7 forwards): C-f (7 times to "S") C-SPACE - kill region (after down and left 3 to "J"): C-n C-b C-b C-b C-w - copy region (after setting mark and down to "J"): C-SPACE C-n M-w - yank back last thing killed (after down to end): C-n C-y - Formatting - use wget to download tiny.R to ~/emacs - open tiny.R: C-x C-f tiny.R Enter - move to line 4: C-n C-n C-n C-n - indent current line: TAB - indent buffer: M-< (jump to top), C-SPACE (set mark), M-> (jump to bottom), M-x indent-region Enter - use wget to download sifting.txt to ~/emacs - open sifting.txt: C-x C-f s TAB Enter - fill paragraph: M-q - Buffers - exit (for a clean slate) C-x C-c - find (open) a few files: - open data.txt: C-x C-f ~/D TAB e TAB d TAB Enter - open tiny.R: C-x C-f t TAB Enter - open sifting.txt: C-x C-f s TAB Enter - list buffers: C-x C-b - visit a buffer from the buffer list: SPACE - close a buffer: C-x k - go to shell buffer: C-z (we'll use this command line soon) - Error Recovery - abort partially typed or executing command: e.g. start to open file, abort: C-x C-f C-g - undo an unwanted change: e.g. open tiny.R, delete two characters and 3rd line, undo: C-x C-f t TAB Enter C-d C-d C-n C-n C-k C-k C-/ C-/ C-/ - The Minibuffer - complete as much as possible: e.g. open tiny.R: C-x C-f TAB t TAB Enter - Type C-x ESC ESC to repeat the last command that used the minibuffer. Then the following keys are defined: - previous minibuffer command: M-p - next minibuffer command: M-n - Incremental Search - find tiny.R: C-x C-f t TAB Enter - search forward for "(": C-s ( - repeat search: C-s C-s C-s C-s C-s C-s - exit search: Enter - search backward for ")": C-r ) C-r C-r - exit search: Enter - Query Replace - find data.txt: C-x C-f d TAB Enter - interactively replace text ("3" with "THREE"): M-% 3 Enter THREE Enter y y y n y - undo 4 times: C-/ C-/ C-/ C-/ - repeat last command (above): C-x ESC ESC, change "THREE" to "_THREE_", Enter - Directory Editor to list and manage files - find directory ("." is shorthand for "current directory"): C-x C-f . - help with directory-editor mode: ? - delete (rather, mark for deleting) 2nd file: C-n d - expunge (delete files marked for deleting): x y - find: f - rename: R tiny.R.save - copy: C tiny.R Enter - create directory: + backup Enter - copy tiny.R.save to backup directory (once on tiny.R.save line): C b TAB Enter - Help - help: M-x help - tutorial: M-x help Enter t