Emacs Notes

emacs logo
  1. Getting Emacs
  2. Help
  3. Miscellaneous Bindings
  4. Using Tags
  5. Dired Commands
  6. Search and Replace (multiple files)
  7. Getting Emacs

    DONT use Debian's package — build this from source. Its easy and more up to date. And make sure you look at the configure results so all the libraries are in place before building.

    Help

    Binding Command Notes
    C-h k help on keys describe function bound to keys
    C-h m help on mode Describe mode functions and bindings
    C-h b current bindings Lists bindings for current buffer
    C-h l history Lists all the keys pressed so far
    ## l completion List what starts with

    Miscellaneous Bindings

    Binding Command Notes
    C-_ undo Undoes very deep yank buffer, one step at a time.
    M-/ dabbrev-completion Autocompletion from tokens list for current buffers.
    M-q fill-paragraph Autoformats paragraph text. It's fairly smart about preserving prefixes, which is useful when replying to with indented quoted sections '>', '>>'. You have to manually put blank lines between prefixed paragraphs, before formatting, otherwise Emacs thinks it's all one paragraph. Also usually does the right thing with numbered/bulletted paragraphs.

    Note: you may have to run e16keyedit to turn off some of the bindings enlightenment captures first.

    Using Tags

    Run tags from a shell in current directory on code extensions. If just one directory, etags *.c *.h is sufficient (in C). For a source tree, do something like this:

    find . -name '*.cpp' -o -name '*.h' -o -name '*.c' -print0 
        | xargs $(ETAGS) --extra=+q --fields=+fksaiS --c++-kinds=+px --append

    Then emacs responds to the following commands:

    Binding Command Notes
    M-. undo Go to symbol definition.
    M-0 M-. dabbrev-completion Go to next match.
    M-* fill-paragraph Return to your starting point.
    M-. M-x tags-search Initiate a tags search.
    M-, M-x tags-search Go to next match.

    Dired Commands

    In a directory (dired) buffer:

    Binding Command Notes
    m select file
    u unselct selected file
    t select all files
    %-m dired-mark-files-regexp Pick files by regex (e.g. .[ch]$' selects all *.h and *.c files
    M-x - dired-do-query-replace-regexp replace all regex matchs with string with query

    Search and Replace (multiple files)

    You can do multi-directory global search and replace on marked files in a Dired. You can get mixed-path files in one Dired using find-dired with a regex. Then clean up with ibuffer when you're done.

    Binding Command Notes
    M-x - find-dired e.g. '-name "*.lisp"'
    t selct all files
    Q query regex search and replace
    M-x - ibuffer launch ibuffer
    *u mark all unsaved buffers with changes
    S save marked buffers
    D delete marked buffers