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

    BindingCommandNotes
    C-h k help on keysdescribe function bound to keys
    C-h mhelp on modeDescribe mode functions and bindings
    C-h bcurrent bindingsLists bindings for current buffer
    C-h lhistoryLists all the keys pressed so far
    ## lcompletionList what starts with

    Miscellaneous Bindings

    BindingCommandNotes
    C-_undoUndoes very deep yank buffer, one step at a time.
    M-/dabbrev-completionAutocompletion from tokens list for current buffers.
    M-qfill-paragraphAutoformats 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:

    BindingCommandNotes
    M-.undoGo to symbol definition.
    M-0 M-.dabbrev-completionGo to next match.
    M-*fill-paragraphReturn to your starting point.
    M-.M-x tags-searchInitiate a tags search.
    M-,M-x tags-searchGo to next match.

    Dired Commands

    In a directory (dired) buffer:

    BindingCommandNotes
    mselect file
    uunselct selected file
    tselect all files
    %-mdired-mark-files-regexpPick files by regex (e.g. .[ch]$' selects all *.h and *.c files
    M-x -dired-do-query-replace-regexpreplace 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.

    BindingCommandNotes
    M-x -find-direde.g. '-name "*.lisp"'
    tselct all files
    Qquery regex search and replace
    M-x -ibufferlaunch ibuffer
    *umark all unsaved buffers with changes
    Ssave marked buffers
    Ddelete marked buffers