This is version . It is not the current version, and thus it cannot be edited.
Back to current version   Restore this version

Emacs Editor#

The emacs editor

Exiting Emacs#

exit ^X^C

Files#

^x ^fread a file into emacs
^x ^ssave a file
^x ssave all files
^x iinsert a file at current location
^x ^wwrite buffer to a named file

Motion#

^a beginning of line
^e end of line
Esc < beginning of buffer
Esc > end of buffer

Deleting#

^d delete character
Esc d delete following word
Esc Del delete previous word
^k delete to end-of-line
Ctl-Shft-Bksp delete line

Locations and Regions#

The current position/location is considered the space between the location of the cursor and the previous character. This is called the point. A point that is remembered is called a mark. A region is between the last mark and the current cursor position (the point).

^space set mark here
^x ^x exchange point and mark
^u ^space go to previous mark

Cutting and Pasting#

Unlike other editors, rather than a single cut / paste buffer where only a single item can be cut and paste at a time, emacs remembers all cuts and copies so that you can paste the last cut or any prior one.

^w delete region and put on kill ring
Esc w copy region to kill ring
^y yank back (paste) the last thing in the kill ring
Esc y replace last yank with prior thing in the kill ring

Incremental Search#

Incremental search differs from a typical search feature in that it starts the search with the first character and refines the search as you type each subsequent character in the search. This way one may find what one is looking for as soon as possible without typing any more characters than necessary.

^s incremental search forward
^r incremental search backward
^g abort search

^s and ^r can be used while searching in order to find the next occurrence.

Search and Replace#

Esc % interactive search & replace
Esc x query-replace-regexp interactive search & replace utilizing regular expressions

The following valid responses are accepted during the interactive search and replace process.

space replace and find next
del no replace, find next
! replace all remaining non-interactively
^ go back to previous find
, replace current one and don't find next
return exit function
^r recursive edit *
  • recursive edit allows you to go back to a normal edit process. You then type "Esc ^c" to exist the recursive edit and return to the search and replace process.

Buffers#

In general, buffers contain files being edited. Emacs can edit any number of files at a time. Emacs also supports multiple windows. Each window would display a particular buffer. Emacs can display any number of windows with any buffer (or the same buffer) at a time. In general, buffers have the same name as the file they hold.

Killing a buffer that contains changes to a file that you have not yet saved will cause the changes to be lost. However, emacs will warn you about this so that it doesn't happen accidentally.

^x b select a different buffer to be displayed in the current window
^x ^b list all buffers
^x k kill a buffer

Multiple Windows#

Window operations do not affect buffers. It only affects what is displayed. So, killing or creating windows does not affect files.

When you split the screen you will see two copies of the same file that may be navigated independently. Generally, after you split a window you would place a different buffer (representing a different file) in the window by either utilizing a file command or buffer command.

^x 2 split current window above and below
^x 3 split window side-by-side
^x 1 delete all other windows (doesn't hurt the buffers)
^x 0 delete the current window

Keyboard Macros#

Emacs can remember a sequence of keys and emacs commands and be made to repeat them.

^x ( start learning a sequence
^x ) stop learning and remember the sequence as a macro
^x e execute the last learned macro

Registers#

Emacs has the ability to save and name any number of locations and text that has been cut or copied. Each location or block of text is saved in a register. Registers are simply variables with single character names. The name used is up to you. Emacs will ask you for the name.

^x r s save marked region in a named register
^x r i insert saved region into the current location

^x r space save the current location in a named register
^x r j jump to the location previously saved

Add new attachment

Only authorized users are allowed to upload new attachments.
« This particular version was published on 28-Aug-2013 12:40 by BlakeMcBride.