|
|
1.1 ! root 1: Info file emacs, produced by texinfo-format-buffer -*-Text-*- ! 2: from file emacs.tex ! 3: ! 4: This file documents the GNU Emacs editor. ! 5: ! 6: Copyright (C) 1985, 1986 Richard M. Stallman. ! 7: ! 8: Permission is granted to make and distribute verbatim copies of ! 9: this manual provided the copyright notice and this permission notice ! 10: are preserved on all copies. ! 11: ! 12: Permission is granted to copy and distribute modified versions of this ! 13: manual under the conditions for verbatim copying, provided also that the ! 14: sections entitled "The GNU Manifesto", "Distribution" and "GNU Emacs ! 15: General Public License" are included exactly as in the original, and ! 16: provided that the entire resulting derived work is distributed under the ! 17: terms of a permission notice identical to this one. ! 18: ! 19: Permission is granted to copy and distribute translations of this manual ! 20: into another language, under the above conditions for modified versions, ! 21: except that the sections entitled "The GNU Manifesto", "Distribution" ! 22: and "GNU Emacs General Public License" may be included in a translation ! 23: approved by the author instead of in the original English. ! 24: ! 25: ! 26: File: emacs Node: Reverting, Prev: Saving, Up: Files, Next: Auto Save ! 27: ! 28: Reverting a Buffer ! 29: ================== ! 30: ! 31: If you have made extensive changes to a file and then change your mind ! 32: about them, you can get rid of them by reading in the previous version of ! 33: the file. To do this, use `M-x revert-buffer', which operates on the ! 34: current buffer. Since this is a very dangerous thing to do, you must ! 35: confirm it with `yes'. ! 36: ! 37: If the current buffer has been auto-saved more recently than it has been ! 38: saved for real, `revert-buffer' offers to read the auto save file ! 39: instead of the visited file (*Note Auto Save::). This question comes ! 40: before the usual request for confirmation, and demands `y' or `n' ! 41: as an answer. If you have started to type `yes' for confirmation ! 42: without realizing that the other question was going to be asked, the ! 43: `y' will answer that question, but the `es' will not be valid ! 44: confirmation. So you will have a chance to cancel the operation with ! 45: `C-g' and try it again with the answers that you really intend. ! 46: ! 47: `revert-buffer' keeps point at the same distance (measured in ! 48: characters) from the beginning of the file. If the file was edited only ! 49: slightly, you will be at approximately the same piece of text after ! 50: reverting as before. If you have made drastic changes, the same value of ! 51: point in the old file may address a totally different piece of text. ! 52: ! 53: A buffer reverted from its visited file is marked "not modified" until ! 54: another change is made. ! 55: ! 56: Some kinds of buffers whose contents reflect data bases other than files, ! 57: such as Dired buffers, can also be reverted. For them, reverting means ! 58: recalculating their contents from the appropriate data base. Buffers ! 59: created randomly with `C-x b' cannot be reverted; `revert-buffer' ! 60: reports an error when asked to do so. ! 61: ! 62: ! 63: File: emacs Node: Auto Save, Prev: Reverting, Up: Files, Next: ListDir ! 64: ! 65: Auto-Saving: Protection Against Disasters ! 66: ========================================= ! 67: ! 68: Emacs saves all the visited files from time to time (based on counting ! 69: your keystrokes) without being asked. This is called "auto-saving". ! 70: It prevents you from losing more than a limited amount of work if the ! 71: system crashes. ! 72: ! 73: When Emacs determines that it is time for auto-saving, each buffer is ! 74: considered, and is auto-saved if auto-saving is turned on for it and it has ! 75: been changed since the last time it was auto-saved. If any auto-saving is ! 76: done, the message `Auto-saving...' is displayed in the echo area until ! 77: auto-saving is finished. Errors occurring during auto-saving are caught ! 78: so that they do not interfere with the execution of commands you have been ! 79: typing. ! 80: ! 81: * Menu: ! 82: ! 83: * Files: Auto Save Files. ! 84: * Control: Auto Save Control. ! 85: * Recover:: Recovering text from auto-save files. ! 86: ! 87: ! 88: File: emacs Node: Auto Save Files, Prev: Auto Save, Up: Auto Save, Next: Auto Save Control ! 89: ! 90: Auto-Save Files ! 91: --------------- ! 92: ! 93: Auto-saving does not normally save in the files that you visited, because ! 94: it can be very undesirable to save a program that is in an inconsistent ! 95: state when you have made half of a planned change. Instead, auto-saving ! 96: is done in a different file called the "auto-save file", and the ! 97: visited file is changed only when you request saving explicitly (such as ! 98: with `C-x C-s'). ! 99: ! 100: Normally, the auto-save file name is made by appending `#' to the ! 101: front and rear of the visited file name. Thus, a buffer visiting file ! 102: `foo.c' would be auto-saved in a file `#foo.c#'. Most buffers ! 103: that are not visiting files are auto-saved only if you request it ! 104: explicitly; when they are auto-saved, the auto-save file name is made by ! 105: appending `#%' to the front and `#' to the rear of buffer name. ! 106: For example, the `*mail*' buffer in which you compose messages to be ! 107: sent is auto-saved in a file named `#%*mail*#'. Auto-save file names ! 108: are made this way unless you reprogram parts of Emacs to do something ! 109: different (the functions `make-auto-save-file-name' and ! 110: `auto-save-file-name-p'). The file name to be used for auto-saving ! 111: in a buffer is calculated when auto-saving is turned on in that buffer. ! 112: ! 113: If you want auto-saving to be done in the visited file, set the variable ! 114: `auto-save-visited-file-name' to be non-`nil'. In this mode, ! 115: there is really no difference between auto-saving and explicit saving. ! 116: ! 117: A buffer's auto-save file is deleted when you save the buffer in its ! 118: visited file. To inhibit this, set the variable `delete-auto-save-files' ! 119: to `nil'. Changing the visited file name with `C-x C-w' or ! 120: `set-visited-file-name' renames any auto-save file to go with ! 121: the new visited name. ! 122: ! 123: ! 124: File: emacs Node: Auto Save Control, Prev: Auto Save Files, Up: Auto Save, Next: Recover ! 125: ! 126: Controlling Auto-Saving ! 127: ----------------------- ! 128: ! 129: Each time you visit a file, auto-saving is turned on for that file's ! 130: buffer if the variable `auto-save-default' is non-`nil' (but not ! 131: in batch mode; *Note Entering Emacs::). The default for this variable is ! 132: `t', so auto-saving is the usual practice for file-visiting buffers. ! 133: Auto-saving can be turned on or off for any existing buffer with the ! 134: command `M-x auto-save-mode'. Like other minor mode commands, `M-x ! 135: auto-save-mode' turns auto-saving on with a positive argument, off with a ! 136: zero or negative argument; with no argument, it toggles. ! 137: ! 138: Emacs does auto-saving periodically based on counting how many characters ! 139: you have typed since the last time auto-saving was done. The variable ! 140: `auto-save-interval' specifies how many characters there are between ! 141: auto-saves. By default, it is 300. Emacs also auto-saves whenever you ! 142: call the function `do-auto-save'. ! 143: ! 144: Emacs also does auto-saving whenever it gets a fatal error. This ! 145: includes killing the Emacs job with a shell command such as `kill ! 146: %emacs', or disconnecting a phone line or network connection. ! 147: ! 148: ! 149: File: emacs Node: Recover, Prev: Auto Save Control, Up: Auto Save ! 150: ! 151: Recovering Data from Auto-Saves ! 152: ------------------------------- ! 153: ! 154: The way to use the contents of an auto-save file to recover from a loss ! 155: of data is with the command `M-x recover-file RET FILE RET'. This visits ! 156: FILE and then (after your confirmation) restores the contents from from its ! 157: auto-save file `#FILE#'. You can then save with `C-x C-s' to put the ! 158: recovered text into FILE itself. For example, to recover file `foo.c' from ! 159: its auto-save file `#foo.c#', do: ! 160: ! 161: M-x recover-file RET foo.c RET ! 162: C-x C-s ! 163: ! 164: Before asking for confirmation, `M-x recover-file' displays a ! 165: directory listing describing the specified file and the auto-save file, ! 166: so you can compare their sizes and dates. If the auto-save file ! 167: is older, `M-x recover-file' does not offer to read it. ! 168: ! 169: Auto-saving is disabled by `M-x recover-file' because using ! 170: this command implies that the auto-save file contains valuable data ! 171: from a past session. If you save the data in the visited file and ! 172: then go on to make new changes, you should turn auto-saving back on ! 173: with `M-x auto-save-mode'. ! 174: ! 175: ! 176: File: emacs Node: ListDir, Prev: Auto Save, Up: Files, Next: Dired ! 177: ! 178: Listing a File Directory ! 179: ======================== ! 180: ! 181: Files are classified by Unix into "directories". A "directory ! 182: listing" is a list of all the files in a directory. Emacs provides ! 183: directory listings in brief format (file names only) and verbose format ! 184: (sizes, dates, and authors included). ! 185: ! 186: `C-x C-d DIR-OR-PATTERN' ! 187: Print a brief directory listing (`list-directory'). ! 188: `C-u C-x C-d DIR-OR-PATTERN' ! 189: Print a verbose directory listing. ! 190: ! 191: The command to print a directory listing is `C-x C-d' (`list-directory'). ! 192: It reads using the minibuffer a file name which is either a directory to be ! 193: listed or a wildcard-containing pattern for the files to be listed. For ! 194: example, ! 195: ! 196: C-x C-d /u2/emacs/etc RET ! 197: ! 198: lists all the files in directory `/u2/emacs/etc'. An example of ! 199: specifying a file name pattern is ! 200: ! 201: C-x C-d /u2/emacs/src/*.c RET ! 202: ! 203: Normally, `C-x C-d' prints a brief directory listing containing just ! 204: file names. A numeric argument (regardless of value) tells it to print a ! 205: verbose listing (like `ls -l'). ! 206: ! 207: The text of a directory listing is obtained by running `ls' in an ! 208: inferior process. Two Emacs variables control the switches passed to ! 209: `ls': `list-directory-brief-switches' is a string giving the ! 210: switches to use in brief listings (`"-CF"' by default), and ! 211: `list-directory-verbose-switches' is a string giving the switches to ! 212: use in a verbose listing (`"-l"' by default). ! 213: ! 214: ! 215: File: emacs Node: Dired, Prev: ListDir, Up: Files, Next: Misc File Ops ! 216: ! 217: Dired, the Directory Editor ! 218: =========================== ! 219: ! 220: Dired makes it easy to delete or visit many of the files in a single ! 221: directory at once. It makes an Emacs buffer containing a listing of the ! 222: directory. You can use the normal Emacs commands to move around in this ! 223: buffer, and special Dired commands to operate on the files. ! 224: ! 225: * Menu: ! 226: ! 227: * Enter: Dired Enter. How to invoke Dired. ! 228: * Edit: Dired Edit. Editing the Dired buffer. ! 229: * Deletion: Dired Deletion. Deleting files with Dired. ! 230: * Immed: Dired Immed. Other file operations through Dired. ! 231: ! 232: ! 233: File: emacs Node: Dired Enter, Prev: Dired, Up: Dired, Next: Dired Edit ! 234: ! 235: Entering Dired ! 236: -------------- ! 237: ! 238: To invoke dired, do `C-x d' or `M-x dired'. The command reads a ! 239: directory name or wildcard file name pattern as a minibuffer argument just ! 240: like the `list-directory' command, `C-x C-d'. Where `dired' ! 241: differs from `list-directory' is in naming the buffer after the ! 242: directory name or the wildcard pattern used for the listing, and putting ! 243: the buffer into Dired mode so that the special commands of Dired are ! 244: available in it. The variable `dired-listing-switches' is a string ! 245: used as an argument to `ls' in making the directory; this string ! 246: must contain `-l'. ! 247: ! 248: To display the Dired buffer in another window rather than in the selected ! 249: window, use `C-x 4 d' (`dired-other-window)' instead of `C-x d'. ! 250: ! 251: ! 252: File: emacs Node: Dired Edit, Prev: Dired Enter, Up: Dired, Next: Dired Deletion ! 253: ! 254: Editing in Dired ! 255: ---------------- ! 256: ! 257: Once the Dired buffer exists, you can switch freely between it and other ! 258: Emacs buffers. Whenever the Dired buffer is selected, certain special ! 259: commands are provided that operate on files that are listed. The Dired ! 260: buffer is "read-only", and inserting text in it is not useful, so ! 261: ordinary printing characters such as `d' and `x' are used for Dired ! 262: commands. Most Dired commands operate on the file described by the line ! 263: that point is on. Some commands perform operations immediately; others ! 264: "flag" the file to be operated on later. ! 265: ! 266: Most Dired commands that operate on the current line's file also treat a ! 267: numeric argument as a repeat count, meaning to act on the files of the ! 268: next few lines. A negative argument means to operate on the files of the ! 269: preceding lines, and leave point on the first of those lines. ! 270: ! 271: All the usual Emacs cursor motion commands are available in Dired ! 272: buffers. Some special purpose commands are also provided. The keys ! 273: `C-n' and `C-p' are redefined so that they try to position ! 274: the cursor at the beginning of the filename on the line, rather than ! 275: at the beginning of the line. ! 276: ! 277: For extra convenience, SPC and `n' in Dired are equivalent to `C-n'. `p' ! 278: is equivalent to `C-p'. Moving by lines is done so often in Dired that it ! 279: deserves to be easy to type. DEL (move up and unflag) is often useful ! 280: simply for moving up. ! 281: ! 282: The `g' command in Dired runs `revert-buffer' to reinitialize ! 283: the buffer from the actual disk directory and show any changes made in the ! 284: directory by programs other than Dired. All deletion flags in the Dired ! 285: buffer are lost when this is done. ! 286: ! 287: ! 288: File: emacs Node: Dired Deletion, Prev: Dired Edit, Up: Dired, Next: Dired Immed ! 289: ! 290: Deleting Files with Dired ! 291: ------------------------- ! 292: ! 293: The primary use of Dired is to flag files for deletion and then delete ! 294: them. ! 295: ! 296: `d' ! 297: Flag this file for deletion. ! 298: `u' ! 299: Remove deletion-flag on this line. ! 300: `DEL' ! 301: Remove deletion-flag on previous line, moving point to that line. ! 302: `x' ! 303: Delete the files that are flagged for deletion. ! 304: `#' ! 305: Flag all auto-save files (files whose names start and end with `#') ! 306: for deletion (*Note Auto Save::). ! 307: `~' ! 308: Flag all backup files (files whose names end with `~') for deletion ! 309: (*Note Backup::). ! 310: `. (Period)' ! 311: Flag excess numeric backup files for deletion. The oldest and newest ! 312: few backup files of any one file are exempt; the middle ones are flagged. ! 313: ! 314: You can flag a file for deletion by moving to the line describing the ! 315: file and typing `d' or `C-d'. The deletion flag is visible as a ! 316: `D' at the beginning of the line. Point is moved to the beginning of ! 317: the next line, so that repeated `d' commands flag successive files. ! 318: ! 319: The files are flagged for deletion rather than deleted immediately to ! 320: avoid the danger of deleting a file accidentally. Until you direct Dired ! 321: to delete the flagged files, you can remove deletion flags using the ! 322: commands `u' and DEL. `u' works just like `d', but ! 323: removes flags rather than making flags. DEL moves upward, removing ! 324: flags; it is like `u' with numeric argument automatically negated. ! 325: ! 326: To delete the flagged files, type `x'. This command first displays a ! 327: list of all the file names flagged for deletion, and requests confirmation ! 328: with `yes'. Once you confirm, all the flagged files are deleted, and their ! 329: lines are deleted from the text of the Dired buffer. The shortened Dired ! 330: buffer remains selected. If you answer `no' or quit with `C-g', you ! 331: return immediately to Dired, with the deletion flags still present and no ! 332: files actually deleted. ! 333: ! 334: The `#', `~' and `.' commands flag many files for deletion, based on ! 335: their names. These commands are useful precisely because they do not ! 336: actually delete any files; you can remove the deletion flags from any ! 337: flagged files that you really wish to keep. ! 338: ! 339: `#' flags for deletion all files that appear to have been made by ! 340: auto-saving (that is, files whose names begin and end with `#'). ! 341: `~' flags for deletion all files that appear to have been made as ! 342: backups for files that were edited (that is, files whose names end with ! 343: `~'). ! 344: ! 345: `.' (Period) flags just some of the backup files for deletion: only ! 346: numeric backups that are not among the oldest few nor the newest few ! 347: backups of any one file. Normally `dired-kept-versions' (not ! 348: `kept-new-versions'; that applies only when saving) specifies the number of ! 349: newest versions of each file to keep, and `kept-old-versions' specifies the ! 350: number of oldest versions to keep. Period with a positive numeric ! 351: argument, as in `C-u 3 .', specifies the number of newest versions to keep, ! 352: overriding `dired-kept-versions'. A negative numeric argument overrides ! 353: `kept-old-versions', using minus the value of the argument to specify the ! 354: number of oldest versions of each file to keep. ! 355: ! 356: ! 357: File: emacs Node: Dired Immed, Prev: Dired Deletion, Up: Dired ! 358: ! 359: Immediate File Operations in Dired ! 360: ---------------------------------- ! 361: ! 362: Some file operations in Dired take place immediately when they are ! 363: requested. ! 364: ! 365: `c' ! 366: Copies the file described on the current line. You must supply a file name ! 367: to copy to, using the minibuffer. ! 368: `f' ! 369: Visits the file described on the current line. It is just like typing ! 370: `C-x C-f' and supplying that file name. If the file on this line is a ! 371: subdirectory, `f' actually causes Dired to be invoked on that ! 372: subdirectory. *Note Visiting::. ! 373: `o' ! 374: Like `f', but uses another window to display the file's buffer. The ! 375: Dired buffer remains visible in the first window. This is like using ! 376: `C-x 4 C-f' to visit the file. *Note Windows::. ! 377: `r' ! 378: Renames the file described on the current line. You must supply a file ! 379: name to rename to, using the minibuffer. ! 380: `v' ! 381: Views the file described on this line using `M-x view-file'. Viewing ! 382: a file is like visiting it, but is slanted toward moving around in the ! 383: file conveniently and does not allow changing the file. *Note View ! 384: File: Misc File Ops. Viewing a file that is a directory runs Dired on ! 385: that directory. ! 386: ! 387: ! 388: File: emacs Node: Misc File Ops, Prev: Dired, Up: Files ! 389: ! 390: Miscellaneous File Operations ! 391: ============================= ! 392: ! 393: Emacs has commands for performing many other operations on files. ! 394: All operate on one file; they do not accept wild card file names. ! 395: ! 396: `M-x view-file' allows you to scan or read a file by sequential ! 397: screenfuls. It reads a file name argument using the minibuffer. After ! 398: reading the file into an Emacs buffer, `view-file' reads and displays ! 399: one windowful. You can then type SPC to scroll forward one windowful, ! 400: or DEL to scroll backward. Various other commands are provided for ! 401: moving around in the file, but none for changing it; type `C-h' while ! 402: viewing for a list of them. They are mostly the same as normal Emacs ! 403: cursor motion commands. To exit from viewing, type `C-c'. ! 404: ! 405: `M-x insert-file' inserts a copy of the contents of the specified ! 406: file into the current buffer at point, leaving point unchanged before the ! 407: contents and the mark after them. *Note Mark::. ! 408: ! 409: `M-x write-region' is the inverse of `M-x insert-file'; it copies ! 410: the contents of the region into the specified file. `M-x append-to-file' ! 411: adds the text of the region to the end of the specified file. ! 412: ! 413: `M-x delete-file' deletes the specified file, like the `rm' ! 414: command in the shell. If you are deleting many files in one directory, it ! 415: may be more convenient to use Dired (*Note Dired::). ! 416: ! 417: `M-x rename-file' reads two file names OLD and NEW using ! 418: the minibuffer, then renames file OLD as NEW. If a file named ! 419: NEW already exists, you must confirm with `yes' or renaming is not ! 420: done; this is because renaming causes the old meaning of the name NEW ! 421: to be lost. If OLD and NEW are on different file systems, the ! 422: file OLD is copied and deleted. ! 423: ! 424: The similar command `M-x add-name-to-file' is used to add an ! 425: additional name to an existing file without removing its old name. ! 426: The new name must belong on the same file system that the file is on. ! 427: ! 428: `M-x copy-file' reads the file OLD and writes a new file named ! 429: NEW with the same contents. Confirmation is required if a file named ! 430: NEW already exists, because copying has the consequence of overwriting ! 431: the old contents of the file NEW. ! 432: ! 433: `M-x make-symbolic-link' reads two file names OLD and LINKNAME, ! 434: and then creates a symbolic link named LINKNAME and pointing at OLD. ! 435: The effect is that future attempts to open file LINKNAME will refer ! 436: to whatever file is named OLD at the time the opening is done, or ! 437: will get an error if the name OLD is not in use at that time. ! 438: Confirmation is required when creating the link if LINKNAME is in ! 439: use. Note that not all systems support symbolic links. ! 440: ! 441: ! 442: File: emacs Node: Buffers, Prev: Files, Up: Top, Next: Windows ! 443: ! 444: Using Multiple Buffers ! 445: ********************** ! 446: ! 447: The text you are editing in Emacs resides in an object called a ! 448: "buffer". Each time you visit a file, a buffer is created to hold the ! 449: file's text. Each time you invoke Dired, a buffer is created to hold the ! 450: directory listing. If you send a message with `C-x m', a buffer named ! 451: `*mail*' is used to hold the text of the message. When you ask for a ! 452: command's documentation, that appears in a buffer called `*Help*'. ! 453: ! 454: At any time, one and only one buffer is "selected". It is also ! 455: called the "current buffer". Often we say that a command operates on ! 456: "the buffer" as if there were only one; but really this means that the ! 457: command operates on the selected buffer (most commands do). ! 458: ! 459: When Emacs makes multiple windows, each window has a chosen buffer which ! 460: is displayed there, but at any time only one of the windows is selected and ! 461: its chosen buffer is the selected buffer. Each window's mode line displays ! 462: the name of the buffer that the window is displaying (*Note Windows::). ! 463: ! 464: Each buffer has a name, which can be of any length, and you can select ! 465: any buffer by giving its name. Most buffers are made by visiting files, ! 466: and their names are derived from the files' names. But you can also create ! 467: an empty buffer with any name you want. A newly started Emacs has a buffer ! 468: named `*scratch*' which can be used for evaluating Lisp expressions in ! 469: Emacs. The distinction between upper and lower case matters in buffer ! 470: names. ! 471: ! 472: Each buffer records individually what file it is visiting, whether it is ! 473: modified, and what major mode and minor modes are in effect in it ! 474: (*Note Major Modes::). Any Emacs variable can be made "local to" a ! 475: particular buffer, meaning its value in that buffer can be different from ! 476: the value in other buffers. *Note Locals::. ! 477: ! 478: * Menu: ! 479: ! 480: * Select Buffer:: Creating a new buffer or reselecting an old one. ! 481: * List Buffers:: Getting a list of buffers that exist. ! 482: * Misc Buffer:: Renaming; changing read-onliness; copying text. ! 483: * Kill Buffer:: Killing buffers you no longer need. ! 484: * Several Buffers:: How to go through the list of all buffers ! 485: and operate variously on several of them. ! 486: ! 487: ! 488: File: emacs Node: Select Buffer, Prev: Buffers, Up: Buffers, Next: List Buffers ! 489: ! 490: Creating and Selecting Buffers ! 491: ============================== ! 492: ! 493: `C-x b BUFFER RET' ! 494: Select or create a buffer named BUFFER (`switch-to-buffer'). ! 495: `C-x 4 b BUFFER RET' ! 496: Similar but select a buffer named BUFFER in another window ! 497: (`switch-to-buffer-other-window'). ! 498: ! 499: To select the buffer named BUFNAME, type `C-x b BUFNAME RET'. This is ! 500: the command `switch-to-buffer' with argument BUFNAME. You can use ! 501: completion on an abbreviation for the buffer name you want (*Note ! 502: Completion::). An empty argument to `C-x b' specifies the most recently ! 503: selected buffer that is not displayed in any window. ! 504: ! 505: Most buffers are created by visiting files, or by Emacs commands that ! 506: want to display some text, but you can also create a buffer explicitly by ! 507: typing `C-x b BUFNAME RET'. This makes a new, empty buffer which ! 508: is not visiting any file, and selects it for editing. Such buffers are ! 509: used for making notes to yourself. If you try to save one, you are asked ! 510: for the file name to use. The new buffer's major mode is determined by the ! 511: value of `default-major-mode' (*Note Major Modes::). ! 512: ! 513: Note that `C-x C-f', and any other command for visiting a file, can ! 514: also be used to switch buffers. *Note Visiting::. ! 515: ! 516: ! 517: File: emacs Node: List Buffers, Prev: Select Buffer, Up: Buffers, Next: Misc Buffer ! 518: ! 519: Listing Existing Buffers ! 520: ======================== ! 521: ! 522: `C-x C-b' ! 523: List the existing buffers (`list-buffers'). ! 524: ! 525: To print a list of all the buffers that exist, type `C-x C-b'. Each line ! 526: in the list shows one buffer's name, major mode and visited file. `*' at ! 527: the beginning of a line indicates the buffer is "modified". If several ! 528: buffers are modified, it may be time to save some with `C-x s' (*Note ! 529: Saving::). `%' indicates a read-only buffer. `.' marks the selected ! 530: buffer. Here is an example of a buffer list: ! 531: ! 532: MR Buffer Size Mode File ! 533: -- ------ ---- ---- ---- ! 534: .* emacs.tex 383402 Texinfo /u2/emacs/man/emacs.tex ! 535: *Help* 1287 Fundamental ! 536: files.el 23076 Emacs-Lisp /u2/emacs/lisp/files.el ! 537: % RMAIL 64042 RMAIL /u/rms/RMAIL ! 538: *% man 747 Dired ! 539: net.emacs 343885 Fundamental /u/rms/net.emacs ! 540: fileio.c 27691 C /u2/emacs/src/fileio.c ! 541: NEWS 67340 Text /u2/emacs/etc/NEWS ! 542: *scratch* 0 Lisp Interaction ! 543: ! 544: Note that the buffer `*Help*' was made by a help request; it is not ! 545: visiting any file. The buffer `man' was made by Dired on the ! 546: directory `/u2/emacs/man/'. ! 547: ! 548: ! 549: File: emacs Node: Misc Buffer, Prev: List Buffers, Up: Buffers, Next: Kill Buffer ! 550: ! 551: Miscellaneous Buffer Operations ! 552: =============================== ! 553: ! 554: `C-x C-q' ! 555: Toggle read-only status of buffer (`toggle-read-only'). ! 556: `M-x rename-buffer' ! 557: Change the name of the current buffer. ! 558: `M-x view-buffer' ! 559: Scroll through a buffer. ! 560: ! 561: A buffer can be "read-only", which means that commands to change its ! 562: text are not allowed. Normally, read-only buffers are made by subsystems ! 563: such as Dired and Rmail that have special commands to operate on the text; ! 564: a read-only buffer is also made if you visit a file that is protected so ! 565: you cannot write it. If you wish to make changes in a read-only buffer, ! 566: use the command `C-x C-q' (`toggle-read-only'). It makes a ! 567: read-only buffer writable, and makes a writable buffer read-only. This ! 568: works by setting the variable `buffer-read-only', which has a local ! 569: value in each buffer and makes the buffer read-only if its value is ! 570: non-`nil'. ! 571: ! 572: `M-x rename-buffer' changes the name of the current buffer. Specify ! 573: the new name as a minibuffer argument. There is no default. If you ! 574: specify a name that is in use for some other buffer, an error happens and ! 575: no renaming is done. ! 576: ! 577: `M-x view-buffer' is much like `M-x view-file' (*Note Misc File Ops::) ! 578: except that it examines an already existing Emacs buffer. View mode ! 579: provides commands for scrolling through the buffer conveniently but not ! 580: for changing it. When you exit View mode, the value of point that resulted ! 581: from your perusal remains in effect. ! 582: ! 583: The commands `C-x a' (`append-to-buffer') and `M-x insert-buffer' can be ! 584: used to copy text from one buffer to another. *Note Accumulating Text::. ! 585: ! 586: ! 587: File: emacs Node: Kill Buffer, Prev: Misc Buffer, Up: Buffers, Next: Several Buffers ! 588: ! 589: Killing Buffers ! 590: =============== ! 591: ! 592: After you use Emacs for a while, you may accumulate a large number of ! 593: buffers. You may then find it convenient to eliminate the ones you no ! 594: longer need. There are several commands provided for doing this. ! 595: ! 596: `C-x k' ! 597: Kill a buffer, specified by name (`kill-buffer'). ! 598: `M-x kill-some-buffers' ! 599: Offer to kill each buffer, one by one. ! 600: ! 601: ! 602: `C-x k' (`kill-buffer') kills one buffer, whose name you specify ! 603: in the minibuffer. The default, used if you type just RET in the ! 604: minibuffer, is to kill the current buffer. If the current buffer is ! 605: killed, another buffer is selected; a buffer that has been selected ! 606: recently but does not appear in any window now is chosen to be selected. ! 607: If the buffer being killed is modified (has unsaved editing) then you are ! 608: asked to confirm with `yes' before the buffer is killed. ! 609: ! 610: The command `M-x kill-some-buffers' asks about each buffer, one by ! 611: one. An answer of `y' means to kill the buffer. Killing the current ! 612: buffer or a buffer containing unsaved changes selects a new buffer or asks ! 613: for confirmation just like `kill-buffer'. ! 614: ! 615: ! 616: File: emacs Node: Several Buffers, Prev: Kill Buffer, Up: Buffers ! 617: ! 618: Operating on Several Buffers ! 619: ============================ ! 620: ! 621: The "buffer-menu" facility is like a "Dired for buffers"; it allows ! 622: you to request operations on various Emacs buffers by editing an Emacs ! 623: buffer containing a list of them. You can save buffers, kill them ! 624: (here called "deleting" them, for consistency with Dired), or display ! 625: them. ! 626: ! 627: `M-x buffer-menu' ! 628: Begin editing a buffer listing all Emacs buffers. ! 629: ! 630: The command `buffer-menu' writes a list of all Emacs buffers into ! 631: the buffer `*Buffer List*', and selects that buffer in Buffer Menu ! 632: mode. The buffer is read-only, and can only be changed through the special ! 633: commands described in this section. Most of these commands are graphic ! 634: characters. The usual Emacs cursor motion commands can be used in the ! 635: `*Buffer List*' buffer. The following special commands apply to the ! 636: buffer described on the current line. ! 637: ! 638: `d' ! 639: Request to delete (kill) the buffer, then move down. The request ! 640: shows as a `D' on the line, before the buffer name. Requested ! 641: deletions take place when the `x' command is used. ! 642: `k' ! 643: Synonym for `d'. ! 644: `C-d' ! 645: Like `d' but move up afterwards instead of down. ! 646: `s' ! 647: Request to save the buffer. The request shows as an `S' on the ! 648: line. Requested saves take place when the `x' command is used. ! 649: You may request both saving and deletion for the same buffer. ! 650: `~' ! 651: Mark buffer "unmodified". The command `~' does this ! 652: immediately when typed. ! 653: `x' ! 654: Perform previously requested deletions and saves. ! 655: `u' ! 656: Remove any request made for the current line, and move down. ! 657: `DEL' ! 658: Move to previous line and remove any request made for that line. ! 659: ! 660: All the commands that put in or remove flags to request later operations ! 661: also move down a line, and accept a numeric argument as a repeat count, ! 662: unless otherwise specified. ! 663: ! 664: There are also special commands to use the buffer list to select another ! 665: buffer, and to specify one or more other buffers for display in additional ! 666: windows. ! 667: ! 668: `1' ! 669: Select the buffer in a full-screen window. This command takes effect ! 670: immediately. ! 671: `2' ! 672: Immediately set up two windows, with this buffer in one, and the ! 673: previously selected buffer (aside from the buffer `*Buffer List*') ! 674: in the other. ! 675: `f' ! 676: Immediately select the buffer in place of the `*Buffer List*' buffer. ! 677: `o' ! 678: Immediately select the buffer in another window as if by `C-x 4 b', ! 679: leaving `*Buffer List*' visible. ! 680: `q' ! 681: Immediately select this buffer, and also display in other windows any ! 682: buffers previously flagged with the `m' command. If there are no ! 683: such buffers, this command is equivalent to `1'. ! 684: `m' ! 685: Flag this buffer to be displayed in another window if the `q' ! 686: command is used. The request shows as a `>' at the beginning of ! 687: the line. The same buffer may not have both a delete request and a ! 688: display request. ! 689: ! 690: All that `buffer-menu' does directly is create and select a suitable ! 691: buffer, and turn on Buffer Menu mode. Everything else described above is ! 692: implemented by the special commands provided in Buffer Menu mode. One ! 693: consequence of this is that you can switch from the `*Buffer List*' ! 694: buffer to another Emacs buffer, and edit there. You can reselect the ! 695: `buffer-menu' buffer later, to perform the operations already ! 696: requested, or you can kill it, or pay no further attention to it. ! 697: ! 698: The only difference between `buffer-menu' and `list-buffers' is ! 699: that `buffer-menu' selects the `*Buffer List*' buffer and ! 700: `list-buffers' does not. If you run `list-buffers' (that is, ! 701: type `C-x C-b') and select the buffer list manually, you can use all of ! 702: the commands described here. ! 703: ! 704: ! 705: File: emacs Node: Windows, Prev: Buffers, Up: Top, Next: Major Modes ! 706: ! 707: Multiple Windows ! 708: **************** ! 709: ! 710: Emacs can split the screen into two or many windows, which can display ! 711: parts of different buffers, or different parts of one buffer. ! 712: ! 713: * Menu: ! 714: ! 715: * Basic Window:: Introduction to Emacs windows. ! 716: * Split Window:: New windows are made by splitting existing windows. ! 717: * Other Window:: Moving to another window or doing something to it. ! 718: * Pop Up Window:: Finding a file or buffer in another window. ! 719: * Change Window:: Deleting windows and changing their sizes. ! 720: ! 721: ! 722: File: emacs Node: Basic Window, Prev: Windows, Up: Windows, Next: Split Window ! 723: ! 724: Concepts of Emacs Windows ! 725: ========================= ! 726: ! 727: When multiple windows are being displayed, each window has an Emacs ! 728: buffer designated for display in it. The same buffer may appear in more ! 729: than one window; if it does, any changes in its text are displayed in all ! 730: the windows where it appears. But the windows showing the same buffer can ! 731: show different parts of it, because each window has its own value of point. ! 732: ! 733: At any time, one of the windows is the "selected window"; the buffer ! 734: this window is displaying is the current buffer. The terminal's cursor ! 735: shows the location of point in this window. Each other window has a ! 736: location of point as well, but since the terminal has only one cursor there ! 737: is no way to show where those locations are. ! 738: ! 739: Commands to move point affect the value of point for the selected Emacs ! 740: window only. They do not change the value of point in any other Emacs ! 741: window, even one showing the same buffer. The same is true for commands ! 742: such as `C-x b' to change the selected buffer in the selected window; ! 743: they do not affect other windows at all. However, there are other commands ! 744: such as `C-x 4 b' that select a different window and switch buffers in ! 745: it. Also, all commands that display information in a window, including ! 746: (for example) `C-h f' (`describe-function') and `C-x C-b' ! 747: (`list-buffers'), work by switching buffers in a nonselected window ! 748: without affecting the selected window. ! 749: ! 750: Each window has its own mode line, which displays the buffer name, ! 751: modification status and major and minor modes of the buffer that is ! 752: displayed in the window. *Note Mode Line::, for full details on the mode ! 753: line. ! 754: ! 755: ! 756: File: emacs Node: Split Window, Prev: Basic Window, Up: Windows, Next: Other Window ! 757: ! 758: Splitting Windows ! 759: ================= ! 760: ! 761: `C-x 2' ! 762: Split the selected window into two windows, one above the other ! 763: (`split-window-vertically'). ! 764: `C-x 5' ! 765: Split the selected window into two windows positioned side by side ! 766: (`split-window-horizontally'). ! 767: ! 768: The command `C-x 2' (`split-window-vertically') breaks the ! 769: selected window into two windows, one above the other. Both windows start ! 770: out displaying the same buffer, with the same value of point. By default ! 771: the two windows each get half the height of the window that was split; a ! 772: numeric argument specifies how many lines to give to the top window. ! 773: ! 774: `C-x 5' (`split-window-horizontally') breaks the selected ! 775: window into two side-by-side windows. A numeric argument specifies ! 776: how many columns to give the one on the left. A line of vertical bars ! 777: separates the two windows. Windows that are not the full width of the ! 778: screen have mode lines, but they are truncated; also, they do not ! 779: always appear in inverse video, because, the Emacs display routines ! 780: have not been taught how to display a region of inverse video that is ! 781: only part of a line on the screen. ! 782: ! 783: When a window is less than the full width, text lines too long to fit are ! 784: frequent. Continuing all those lines might be confusing. The variable ! 785: `truncate-partial-width-windows' can be set non-`nil' to force truncation ! 786: in all windows less than the full width of the screen, independent of the ! 787: buffer being displayed and its value for `truncate-lines'. *Note ! 788: Continuation Lines::. ! 789: ! 790: Horizontal scrolling is often used in side-by-side windows. ! 791: *Note Display::. ! 792: ! 793: ! 794: File: emacs Node: Other Window, Prev: Split Window, Up: Windows, Next: Pop Up Window ! 795: ! 796: Using Other Windows ! 797: =================== ! 798: ! 799: `C-x o' ! 800: Select another window (`other-window'). That is `o', not zero. ! 801: `C-M-v' ! 802: Scroll the next window (`scroll-other-window'). ! 803: `M-x compare-windows' ! 804: Find next place where the text in the selected window does not match ! 805: the text in the next window. ! 806: ! 807: To select a different window, use `C-x o' (`other-window'). ! 808: That is an `o', for `other', not a zero. When there are more than two ! 809: windows, this command moves through all the windows in a cyclic order, ! 810: generally top to bottom and left to right. From the rightmost and ! 811: bottommost window, it goes back to the one at the upper left corner. A ! 812: numeric argument means to move several steps in the cyclic order of ! 813: windows. A negative argument moves around the cycle in the opposite order. ! 814: When the minibuffer is active, the minibuffer is the last window in the ! 815: cycle; you can switch from the minibuffer window to one of the other ! 816: windows, and later switch back and finish supplying the minibuffer argument ! 817: that is requested. *Note Minibuffer Edit::. ! 818: ! 819: The usual scrolling commands (*Note Display::) apply to the selected ! 820: window only, but there is one command to scroll the next window. ! 821: `C-M-v' (`scroll-other-window') scrolls the window that `C-x o' ! 822: would select. It takes arguments, positive and negative, like `C-v'. ! 823: ! 824: The command `M-x compare-windows' compares the text in the current ! 825: window with that in the next window. Comparison starts at point in each ! 826: window. Point moves forward in each window, a character at a time in each ! 827: window, until the next characters in the two windows are different. Then ! 828: the command is finished. ! 829: ! 830: ! 831: File: emacs Node: Pop Up Window, Prev: Other Window, Up: Windows, Next: Change Window ! 832: ! 833: Displaying in Another Window ! 834: ============================ ! 835: ! 836: `C-x 4' is a prefix key for commands that select another window ! 837: (splitting the window if there is only one) and select a buffer in that ! 838: window. Different `C-x 4' commands have different ways of finding the ! 839: buffer to select. ! 840: ! 841: `C-x 4 b BUFNAME RET' ! 842: Select buffer BUFNAME in another window. This runs ! 843: `switch-to-buffer-other-window'. ! 844: `C-x 4 f FILENAME RET' ! 845: Visit file FILENAME and select its buffer in another window. This ! 846: runs `find-file-other-window'. *Note Visiting::. ! 847: `C-x 4 d DIRECTORY RET' ! 848: Select a Dired buffer for directory DIRECTORY in another window. ! 849: This runs `dired-other-window'. *Note Dired::. ! 850: `C-x 4 m' ! 851: Start composing a mail message in another window. This runs ! 852: `mail-other-window', and its same-window version is `C-x m' ! 853: (*Note Sending Mail::). ! 854: `C-x 4 .' ! 855: Find a tag in the current tag table in another window. This runs ! 856: `find-tag-other-window', the multiple-window variant of `M-.' ! 857: (*Note Tags::). ! 858: ! 859: ! 860: File: emacs Node: Change Window, Prev: Pop Up Window, Up: Windows ! 861: ! 862: Deleting and Rearranging Windows ! 863: ================================ ! 864: ! 865: `C-x 0' ! 866: Get rid of the selected window (`kill-window'). That is a zero. ! 867: `C-x 1' ! 868: Get rid of all windows except the selected one (`delete-other-windows'). ! 869: `C-x ^' ! 870: Make the selected window taller, at the expense of the other(s) ! 871: (`enlarge-window'). ! 872: `C-x }' ! 873: Make the selected window wider (`enlarge-window-horizontally'). ! 874: ! 875: To delete a window, type `C-x 0' (`delete-window'). (That is a ! 876: zero.) The space occupied by the deleted window is distributed among the ! 877: other active windows (but not the minibuffer window, even if that is active ! 878: at the time). Once a window is deleted, its attributes are forgotten; ! 879: there is no automatic way to make another window of the same shape or ! 880: showing the same buffer. But the buffer continues to exist, and you can ! 881: select it in any window with `C-x b'. ! 882: ! 883: `C-x 1' (`delete-other-windows') is more powerful than `C-x 0'; ! 884: it deletes all the windows except the selected one (and the minibuffer); ! 885: the selected window expands to use the whole screen except for the echo ! 886: area. ! 887: ! 888: To readjust the division of space among existing windows, use `C-x ^' ! 889: (`enlarge-window'). It makes the currently selected window get one ! 890: line bigger, or as many lines as is specified with a numeric argument. ! 891: With a negative argument, it makes the selected window smaller. `C-x ! 892: }' (`enlarge-window-horizontally') makes the selected window wider ! 893: by the specified number of columns. The extra screen space given to a ! 894: window comes from one of its neighbors, if that is possible; otherwise, all ! 895: the competing windows are shrunk in the same proportion. If this makes any ! 896: windows too small, those windows are deleted and their space is divided up. ! 897: The minimum size is specified by the variables `window-min-height' and ! 898: `window-min-width'. ! 899: ! 900: ! 901: File: emacs Node: Major Modes, Prev: Windows, Up: Top, Next: Indentation ! 902: ! 903: Major Modes ! 904: *********** ! 905: ! 906: Emacs has many different "major modes", each of which customizes ! 907: Emacs for editing text of a particular sort. The major modes are mutually ! 908: exclusive, and each buffer has one major mode at any time. The mode line ! 909: normally contains the name of the current major mode, in parentheses. ! 910: *Note Mode Line::. ! 911: ! 912: The least specialized major mode is called "Fundamental mode". This ! 913: mode has no mode-specific redefinitions or variable settings, so that each ! 914: Emacs command behaves in its most general manner, and each option is in its ! 915: default state. For editing any specific type of text, such as Lisp code or ! 916: English text, you should switch to the appropriate major mode, such as Lisp ! 917: mode or Text mode. ! 918: ! 919: Selecting a major mode changes the meanings of a few keys to become more ! 920: specifically adapted to the language being edited. The ones which are ! 921: changed frequently are TAB, DEL, and LFD. In addition, ! 922: the commands which handle comments use the mode to determine how comments ! 923: are to be delimited. Many major modes redefine the syntactical properties ! 924: of characters appearing in the buffer. *Note Syntax::. ! 925: ! 926: The major modes fall into three major groups. Lisp mode (which has ! 927: several variants), C mode and Muddle mode are for specific programming ! 928: languages. Text mode, Nroff mode, TeX mode and Outline mode are for ! 929: editing English text. The remaining major modes are not intended for use ! 930: on users' files; they are used in buffers created for specific purposes by ! 931: Emacs, such as Dired mode for buffers made by Dired (*Note Dired::), and ! 932: Mail mode for buffers made by `C-x m' (*Note Sending Mail::), and Shell ! 933: mode for buffers used for communicating with an inferior shell process ! 934: (*Note Interactive Shell::). ! 935: ! 936: Most programming language major modes specify that only blank lines ! 937: separate paragraphs. This is so that the paragraph commands remain useful. ! 938: *Note Paragraphs::. They also cause Auto Fill mode to use the definition of ! 939: TAB to indent the new lines it creates. This is because most lines ! 940: in a program are usually indented. *Note Indentation::. ! 941: ! 942: * Menu: ! 943: ! 944: * Choosing Modes:: How major modes are specified or chosen. ! 945: ! 946: ! 947: File: emacs Node: Choosing Modes, Prev: Major Modes, Up: Major Modes ! 948: ! 949: How Major Modes are Chosen ! 950: ========================== ! 951: ! 952: You can select a major mode explicitly for the current buffer, but ! 953: most of the time Emacs determines which mode to use based on the file ! 954: name or some text in the file. ! 955: ! 956: Explicit selection of a new major mode is done with a `M-x' command. ! 957: From the name of a major mode, add `-mode' to get the name of a ! 958: command to select that mode. Thus, you can enter Lisp mode by executing ! 959: `M-x lisp-mode'. ! 960: ! 961: When you visit a file, Emacs usually chooses the right major mode based ! 962: on the file's name. For example, files whose names end in `.c' are ! 963: edited in C mode. The correspondence between file names and major mode is ! 964: controlled by the variable `auto-mode-alist'. Its value is a list in ! 965: which each element has the form ! 966: ! 967: (REGEXP . MODE-FUNCTION) ! 968: ! 969: For example, one element normally found in the list has the form ! 970: `("\\.c$" . c-mode)', and it is responsible for selecting C mode ! 971: for files whose names end in `.c'. (Note that `\\' is needed in ! 972: Lisp syntax to include a `\' in the string, which is needed to ! 973: suppress the special meaning of `.' in regexps.) The only practical ! 974: way to change this variable is with Lisp code. ! 975: ! 976: You can specify which major mode should be used for editing a certain ! 977: file by a special sort of text in the first nonblank line of the file. The ! 978: mode name should appear in this line both preceded and followed by ! 979: `-*-'. Other text may appear on the line as well. For example, ! 980: ! 981: ;-*-Lisp-*- ! 982: ! 983: tells Emacs to use Lisp mode. Note how the semicolon is used to make Lisp ! 984: treat this line as a comment. Such an explicit specification overrides any ! 985: defaulting based on the file name. ! 986: ! 987: Another format of mode specification is ! 988: ! 989: -*-Mode: MODENAME;-*- ! 990: ! 991: which allows other things besides the major mode name to be specified. ! 992: However, Emacs does not look for anything except the mode name. ! 993: ! 994: The major mode can also be specified in a local variables list. ! 995: *Note File Variables::. ! 996: ! 997: When a file is visited that does not specify a major mode to use, or when ! 998: a new buffer is created with `C-x b', the major mode used is that ! 999: specified by the variable `default-major-mode'. Normally this value ! 1000: is the symbol `fundamental-mode', which specifies Fundamental mode. ! 1001: If `default-major-mode' is `nil', the major mode is taken from ! 1002: the previously selected buffer. ! 1003: ! 1004: ! 1005: File: emacs Node: Indentation, Prev: Major Modes, Up: Top, Next: Text ! 1006: ! 1007: Indentation ! 1008: *********** ! 1009: ! 1010: `TAB' ! 1011: Indent current line "appropriately" in a mode-dependent fashion. ! 1012: `LFD' ! 1013: Perform RET followed by TAB (`newline-and-indent'). ! 1014: `M-^' ! 1015: Merge two lines (`delete-indentation'). This would cancel out ! 1016: the effect of LFD. ! 1017: `C-M-o' ! 1018: Split line at point; text on the line after point becomes a new line ! 1019: indented to the same column that it now starts in (`split-line'). ! 1020: `M-m' ! 1021: Move (forward or back) to the first nonblank character on the current ! 1022: line (`back-to-indentation'). ! 1023: `C-M-\' ! 1024: Indent several lines to same column (`indent-region'). ! 1025: `C-x TAB' ! 1026: Shift block of lines rigidly right or left (`indent-rigidly'). ! 1027: `M-i' ! 1028: Indent from point to the next prespecified tab stop column ! 1029: (`tab-to-tab-stop'). ! 1030: `M-x indent-relative' ! 1031: Indent from point to under an indentation point in the previous line. ! 1032: ! 1033: Most programming languages have some indentation convention. For Lisp ! 1034: code, lines are indented according to their nesting in parentheses. The ! 1035: same general idea is used for C code, though many details are different. ! 1036: ! 1037: Whatever the language, to indent a line, use the TAB command. Each ! 1038: major mode defines this command to perform the sort of indentation ! 1039: appropriate for the particular language. In Lisp mode, TAB aligns ! 1040: the line according to its depth in parentheses. No matter where in the ! 1041: line you are when you type TAB, it aligns the line as a whole. In C ! 1042: mode, TAB implements a subtle and sophisticated indentation style that ! 1043: knows about many aspects of C syntax. ! 1044: ! 1045: In Text mode, TAB runs the command `tab-to-tab-stop', which ! 1046: indents to the next tab stop column. You can set the tab stops with ! 1047: `M-x edit-tab-stops'. ! 1048: ! 1049: * Menu: ! 1050: ! 1051: * Indentation Commands:: Various commands and techniques for indentation. ! 1052: * Tab Stops:: You can set arbitrary "tab stops" and then ! 1053: indent to the next tab stop when you want to. ! 1054: * Just Spaces:: You can request indentation using just spaces. ! 1055: ! 1056: ! 1057: File: emacs Node: Indentation Commands, Prev: Indentation, Up: Indentation, Next: Tab Stops ! 1058: ! 1059: Indentation Commands and Techniques ! 1060: =================================== ! 1061: ! 1062: If you just want to insert a tab character in the buffer, you can type ! 1063: `C-q TAB'. ! 1064: ! 1065: To move over the indentation on a line, do `Meta-m' ! 1066: (`back-to-indentation'). This command, given anywhere on a line, ! 1067: positions point at the first nonblank character on the line. ! 1068: ! 1069: To insert an indented line before the current line, do `C-a C-o ! 1070: TAB'. To make an indented line after the current line, use `C-e ! 1071: LFD'. ! 1072: ! 1073: `C-M-o' (`split-line') moves the text from point to the end of ! 1074: the line vertically down, so that the current line becomes two lines. ! 1075: `C-M-o' first moves point forward over any spaces and tabs. Then it ! 1076: inserts after point a newline and enough indentation to reach the same ! 1077: column point is on. Point remains before the inserted newline; in this ! 1078: regard, `C-M-o' resembles `C-o'. ! 1079: ! 1080: To join two lines cleanly, use the `Meta-^' (`delete-indentation') ! 1081: command to delete the indentation at the front of the current line, and the ! 1082: line boundary as well. They are replaced by a single space, or by no space ! 1083: if at the beginning of a line or before a `)' or after a `('. To ! 1084: delete just the indentation of a line, go to the beginning of the line and ! 1085: use `Meta-\' (`delete-horizontal-space'), which deletes all spaces ! 1086: and tabs around the cursor. ! 1087: ! 1088: There are also commands for changing the indentation of several lines at ! 1089: once. `Control-Meta-\' (`indent-region') gives each line which begins in ! 1090: the region the "usual" indentation by invoking TAB at the beginning of the ! 1091: line. A numeric argument specifies the column to indent to, and each line ! 1092: is shifted left or right so that its first nonblank character appears in ! 1093: that column. `C-x TAB' (`indent-rigidly') moves all of the lines in the ! 1094: region right by its argument (left, for negative arguments). The whole ! 1095: group of lines moves rigidly sideways, which is how the command gets its ! 1096: name. ! 1097: ! 1098: `M-x indent-relative' indents at point based on the previous line ! 1099: (actually, the last nonempty line.) It inserts whitespace at point, moving ! 1100: point, until it is underneath an indentation point in the previous line. ! 1101: An indentation point is the end of a sequence of whitespace or the end of ! 1102: the line. If point is farther right than any indentation point in the ! 1103: previous line, the whitespace before point is deleted and the first ! 1104: indentation point then applicable is used. If no indentation point is ! 1105: applicable even then, `tab-to-tab-stop' is run (see next section). ! 1106: ! 1107: `indent-relative' is the definition of TAB in Indented Text ! 1108: mode. *Note Text::. ! 1109: ! 1110: ! 1111: File: emacs Node: Tab Stops, Prev: Indentation Commands, Up: Indentation, Next: Just Spaces ! 1112: ! 1113: Tab Stops ! 1114: ========= ! 1115: ! 1116: For typing in tables, you can use Text mode's definition of TAB, ! 1117: `tab-to-tab-stop'. This command inserts indentation before point, ! 1118: enough to reach the next tab stop column. If you are not in Text mode, ! 1119: this function can be found on `M-i' anyway. ! 1120: ! 1121: The tab stops used by `M-i' can be set arbitrarily by the user. ! 1122: They are stored in a variable called `tab-stop-list', as a list of ! 1123: column-numbers in increasing order. ! 1124: ! 1125: The convenient way to set the tab stops is using `M-x edit-tab-stops', ! 1126: which creates and selects a buffer containing a description of the tab stop ! 1127: settings. You can edit this buffer to specify different tab stops, and ! 1128: then type `C-c C-c' to make those new tab stops take effect. In the ! 1129: tab stop buffer, `C-c C-c' runs the function ! 1130: `edit-tab-stops-note-changes' rather than its usual definition ! 1131: `save-buffer'. `edit-tab-stops' records which buffer was current ! 1132: when you invoked it, and stores the tab stops back in that buffer; normally ! 1133: all buffers share the same tab stops and changing them in one buffer ! 1134: affects all, but if you happen to make `tab-stop-list' local in one ! 1135: buffer then `edit-tab-stops' in that buffer will edit the local ! 1136: settings. ! 1137: ! 1138: Here is what the text representing the tab stops looks like for ordinary ! 1139: tab stops every eight columns. ! 1140: ! 1141: : : : : : : ! 1142: 0 1 2 3 4 ! 1143: 0123456789012345678901234567890123456789012345678 ! 1144: To install changes, type C-c C-c ! 1145: ! 1146: The first line contains a colon at each tab stop. The remaining lines ! 1147: are present just to help you see where the colons are and know what to do. ! 1148: ! 1149: Note that the tab stops that control `tab-to-tab-stop' have nothing ! 1150: to do with displaying tab characters in the buffer. *Note Display Vars::, ! 1151: for more information on that. ! 1152: ! 1153:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.