1.12. Emacs for Programmers
1.12.1. General Commands
Some of Emacs's commands are common to all supported programming languages.
To | Keystrokes Command Name |
---|---|
Indent each line between the cursor and mark | ESC C-\ indent-region |
Move to the first nonblank character on the line | ESC m back-to-indentation |
Join this line to the previous one | ESC ^ delete-indentation |
Format and indent a comment | ESC ; indent-for-comment |
1.12.2. C, C++, and Java Modes
To | Keystrokes Command Name |
---|---|
Move to the beginning of the current statement | ESC a c-beginning-of-statement |
Move to the end of the current statement | ESC e c-end-of-statement |
Fill the paragraph, preserving indentations and decorations, if in comment | ESC x c-fill-paragraph |
Move to the beginning of current function | ESC C-a beginning-of-defun |
Move to the end of current function | ESC C-e end-of-defun |
Put the cursor at the beginning of function, mark at the end | C-c RETURN c-mark-function |
Indent the entire function according to indentation style | C-c C-q c-indent-defun |
Indent a balanced expression according to indentation style | ESC C-q c-indent-exp |
Toggle auto state, in which Emacs automatically indents or inserts newlines when "electric" characters are typed ( { } : # ; , / *) | C-c C-a c-toggle-auto-state |
Toggle hungry state, in which Emacs deletes groups of spaces with a single DEL | C-c C-d c-toggle-hungry-state |
Toggle auto-hungry state, in which Emacs deletes groups of spaces and the newline that precedes ... |
Get GNU Emacs Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.