Next: , Previous: Semantic, Up: Programs

26.11 Other Features Useful for Editing Programs

Some Emacs commands that aren't designed specifically for editing programs are useful for that nonetheless.

The Emacs commands that operate on words, sentences and paragraphs are useful for editing code. Most symbols names contain words (see Words), while sentences can be found in strings and comments (see Sentences). As for paragraphs, they are defined in most programming language modes to begin and end at blank lines (see Paragraphs). Therefore, judicious use of blank lines to make the program clearer will also provide useful chunks of text for the paragraph commands to work on. Auto Fill mode, if enabled in a programming language major mode, indents the new lines which it creates.

Electric Layout mode (M-x electric-layout-mode) is a global minor mode that automatically inserts newlines when you type certain characters; for example, ‘{’, ‘}’ and ‘;’ in Javascript mode.

Apart from Hideshow mode (see Hideshow), another way to selectively display parts of a program is to use the selective display feature (see Selective Display). Programming modes often also support Outline minor mode (see Outline Mode), which can be used with the Foldout package (see Foldout).