![]() ![]() |
Home > Resources > Computing Resources > Emacs
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| Command | Operation |
| emacs & | Launch empty buffer (no file) in a new, menued, GUI window - PC X-server must be loaded. |
| emacs filename & | Open filename in a new, menued, GUI window - PC X-server must be loaded. |
| emacs -nw | Launch with empty buffer (no file) in current terminal window - without X-window support. |
| emacs -nw filename | Open filename in current terminal window - without X-window support. |
| [Ctrl-x][Ctrl-s] | Save file without quitting - if filename was unspecified at startup, you are prompted for a filename. |
| [Ctrl-x][Ctrl-w] | Save current work to a different file - you are prompted for the location and name of the file. |
| [Ctrl-x][Ctrl-c] | Quit Emacs - if current work is unsaved, you are prompted whether to save work. |
| [Ctrl-x][Ctrl-v] | Find an alternate file and replace it as the file currently being edited - you are prompted for location and name of the file. |
| [Ctrl-x]i | Insert a file at the current cursor position - you are prompted for the location and name of the file. |
NOTE: Each time you perform a save operation in Emacs, the previously saved copy of the file is saved with the same name and a tilde (~) symbol appended. This provides a running backup that you can go back to in the event of a major editing blunder.
Cursor Movement and Scrolling
| Backward | Forward | Unit of Movement |
| [Ctrl-b] or left arrow | [Ctrl-f] or right arrow | character |
| [Esc][b] | [Esc][f] | word |
| [Ctrl-p] or up arrow | [Ctrl-n] or down arrow | line |
| [Ctrl-a] | [Ctrl-e] | beginning (or end) of line |
| [Esc][v] | [Ctrl-v] | screen - this is how you page through a documnent |
| [Esc][<] | [Esc][>] | beginning (or end) of file |
Insert, Delete and Restore Operations
| Command | Operation |
| [Insert] key | Toggles between insert and overwrite mode - note changes to mode line at bottom of screen as toggled. |
| [Delete] or [Backspace] key |
Delete character to left of cursor. |
| [Ctrl-d] | Delete character under the cursor. |
| [Esc][Delete] | Delete previous word. |
| [Esc][d] |
Delete word the cursor is on. |
| [Esc][0][Ctrl-k] | Delete from the beginning of the line to the cursor location. |
| [Ctrl-k] | Delete from cursor to the end of the line - using a second time will delete the carriage return. |
|
[Ctrl-Space] at start of block |
Delete a block of text - place cursor at beginning of block and mark it with the first command; move cursor to end of block and type second command to delete. |
| [Ctrl-y] | Yank back (restore) text from last deletion - the results of several delete operations performed in succession, without intervening commands or typing, are restored in one yank operation. It can also be used to repeatedly paste the same block of text to different locations in the file. |
Search and Replace Operations
| Command | Operation |
| [Ctrl-s] |
Initiates a forward search operation from the current cursor location. You are prompted at the bottom of the screen for a search string. As you type the string, the cursor positions after the last character of the first instance of the string being typed. To find the next instance of the same string, enter [Ctrl-s] again and type the [Enter] key twice. |
| [Ctrl-r] |
Initiates a backward search operation from the current cursor location. You are prompted at the bottom of the screen for a search string. As you type the string, the cursor positions on the first character of the first instance of the string being typed. To find the next instance of the same string, enter [Ctrl-r] again and type the [Enter] key twice. |
| [Esc][%] | Initiates a query replace operation. You are prompted for the search string. After entering the string, type [Enter]. You are prompted for the replace string. Type it and press [Enter]. You are prompted for confirmation. To replace one instance and move on to the next, type [Space]. For a menu of other options, type [?]. |
| [Esc][x]replace-string | Initiates a global replace operation without confirmation. The replace-string (typed exactly as shown) is part of the command. You are prompted for the search string. Type it and press [Enter]. You are prompted for the replacement string. Type it and press [Enter]. All instances of the search string are replaced. |
| [Esc] |
Terminates search and search-replace operations. |
Miscellaneous Commands
| Command | Operation |
| [Ctrl-g] |
General comand to abort any operation in progress or partially entered command. |
| [Ctrl-x][u] |
Undo last edit. This command may be entered repeatedly to undo a series of edits in reverse order. Undo operations may be applied up to the last save operation. |
| [Esc][x]line-number-mode | A toggle that turns line numbering on or off on the mode line. When on, the mode line will display which line in the file the cursor is located on. |
| [Esc][x]auto-fill-mode |
A toggle that turns Fill mode on or off. When on Fill will be displayed on the mode line as the minor mode setting. |
| [Esc][q] | Reformats a paragraph when Fill mode is toggled on. This command is particularly useful when editing text as opposed to program code. It reformats a paragraph that you have edited and aligns text within the fill margin. |
For information on the many advanced features of Emacs, consult the authoritative online documentation from the GNU Project or the published guide from O'Reilly and Associates.
|
Sociology Home | Arts & Sciences Home | Duke University Home |Webmaster | Contact the Department © Copyright 2003-2006, Duke University |