Emacs/PSGML Quick Reference

Moving Your Cursor Around: Regular Emacs Keystrokes

C-f forward-char Or, "cursor right."
C-b backward-char Or, "cursor left."
C-Left backward-word
C-Right forward-word
C-a beginning-of-line
C-e end-of-line
C-v scroll-up Or,"page down."
M-v previous-page Or, "page up."
M-b backward-word
M-f forward-word
M-g goto-line Not a regular Emacs command, but set by a line in the .emacs file described in this chapter.

Moving Your Cursor Around: PSGML Keystrokes

C-M-a sgml-beginning-of-element First data character of current element.
C-M-e sgml-end-of-element Last data character of current element.
C-c C-d sgml-next-data-field Next place where you can enter data.
C-c C-n sgml-up-element Up in element hierarchy, to next character in current element's parent element.
C-M-u sgml-backward-up-element Up in element hierarchy, to beginning of current element's start-tag.
C-M-d sgml-down-element Beginning of current element's next subelement.
C-M-b sgml-backward-element Beginning of current element's previous subelement.
C-M-f sgml-forward-element Right after current element's next component element.

Adding, Deleting, and Moving Text: Regular Emacs Commands

C-d delete-char
C-@ set-mark-command
C-space set-mark-command
C-w kill-region Cut marked region into "clipboard" (kill ring buffer).
C-k kill-line From cursor to end of line.
C-x C-x exchange-point-and-mark Jump cursor to marked region's other boundary.
C-y yank "Paste" from kill ring buffer to cursor position.
M-d kill-word
M-i overwrite-mode A toggle. Not a regular Emacs command, but set by line in .emacs file.
M-q fill-paragraph Justify paragraph.
M-w kill-ring-save Copy to "clipboard" (kill ring buffer).
M-y yank-pop Replace recently yanked text with previously killed or copied text.
M-C-\ indent-region Indent region's lines. In PSGML mode, it indents tags to show element structure.
C-q quoted-insert Insert next entered character literally, even if it's normally part of a command keystroke.

Adding and Removing SGML Markup and Elements

C-c C-e sgml-insert-element
C-c < sgml-insert-tag Insert a start-tag. Best when adding tags to existing text, as opposed to adding a new element whose content you haven't typed yet.
C-c / sgml-insert-end-tag Insert an end-tag. As with C-c <, most valuable when adding tags to existing text.
C-c C-r sgml-tag-region Add start- and end-tags around marked region.
C-c - sgml-untag-element Remove live element's start- and end-tags. Most useful with in-line tags.
C-c C-k sgml-kill-markup Kill a tag, comment, or other piece of markup.
C-c Enter sgml-split-element Or, "make a new element like the current one." Repeat to split higher-level elements.
C-c o sgml-comment A macro added to .emacs file as part of the chapter.
C-M-k sgml-kill-element Kill text from cursor to end of next subelement.
C-space C-M-e C-w Delete remainder of current element.
M-Tab sgml-complete Complete the entity reference, markup declaration, tag or content word at the cursor.
C-M-u C-@ C-M-f M-w Copy current element to kill ring.
C-c C-q sgml-fill-element Justify current element.
C-c + sgml-insert-attribute Edit current element's attribute values using prompts.
C-c C-a sgml-edit-attributes Edit current element's attribute values using a form in a separate Emacs window.

Getting Help and Other Information

C-h Display help menu.
C-h ? help-for-help Describe use of on-line help.
C-h a command-apropos List commands with a certain string in them.
C-h k describe key Describe the next key pressed after C-h k.
C-c C-c sgml-show-context Or, after a C-c C-a, end attribute editing.
C-x ` next-error Find next error in error message window.
C-c C-o sgml-next-trouble-spot Move cursor to next potential markup problem.
C-c C-v sgml-validate Send document instance to validation program.

Controlling Files, Buffers, and Windows

C-x 0 delete-window Delete cursor's current window.
C-x 1 delete-other-windows Make the cursor's window the only one.
C-x 2 split-window-vertically Split into a top and bottom window.
C-x o other-window Repeated pressing cycles cursor through open windows and minibuffer.
C-x b switch-to-buffer Display a different buffer in cursor's current window.
C-x C-b list-buffers List open buffers in a new window.
C-x C-s save-buffer As a disk file.
C-x C-w write-file As a disk file, under a new name if you like.
C-x C-c save-buffers-kill-emacs Answer prompts about saving each current buffer, then quit Emacs.
C-x C-f find-file Open a new or existing file.
C-x i insert-file Insert an existing disk file at the current cursor position.


C-g keyboard-quit Abort current multi-step operation.
C-_ undo Undo last command.

Customized Behavior

C-x ( start-kbd-macro Start recording a macro.
C-x ) end-kbd-macro Stop recording a macro.
C-x e call-last-kbd-macro Execute last recorded macro.
C-x f set-fill-column Set right margin to current cursor position.
M-x execute-extended-command Display Emacs command prompt in minibuffer.

Searching and Replacing

C-s isearch-forward Incremental search forward.
C-r isearch-backward
M-% query-replace Prompts for target and replacement text.