emacs (Editor Macros) is a full-featured, programmable text editor written in a version of Lisp. The user interface is designed to work on character terminals, though a GUI is also supported.
emacs provides "A wide range of functionality beyond text editing, including a project planner, mail and news reader, debugger interface, calendar, IRC client, and more." GNU
Many lightweight clones exist, including uemacs (Micro Emacs) and mg
Commands are entered using Ctrl and Alt in different ways:
command-namecat > .emacs # create configuration file (optional)
(define-key global-map "\C-H" 'backward-delete-char) # override help
(setq make-backup-files nil) # turn off auto backup
(setq column-number-mode t) # show column numbers
(setq scroll-conservatively 1) # scroll by line instead of by half screen
(setq inhibit-startup-screen t) # no startup screen
(electric-indent-mode 0) # disable new indentation feature
cp /etc/passwd pass1 # make a working copy you can write
cp /etc/group group1 # make a working copy of another file
cp /etc/fstab fstab1 # make a working copy of another file
emacs pass1 # start emacs and load pass1
Ctrl+n # next line
Ctrl+f # forward (right)
Ctrl+p # previous line
Ctrl+b # back (left)
Ctrl+e # end of line
Ctrl+a # beginning of line
Alt+m # first nonblank character on line (move)
Ctrl+v # next screen
Alt+f # forward 1 word
Alt+b # back 1 word
Alt+v # previous screen
Alt+> # end of buffer
Alt+< # beginning of buffer
Alt+< # move to top of buffer
Ctrl+s # search forward
1 # find next 1
0 # find next 10
Ctrl+s # find next 10 (repeat search)
0 # find next 100
Enter # terminate search, leave cursor where it is
Ctrl+r # reverse search
1 # find previous 1
Ctrl+r # find previous 1 (repeat search)
0 # (zero) find previous 10
Bksp # remove last character from search, return to last 1 found
1 # (one) find previous 11
Ctrl+g # abort search, or any uncompleted command (may need to hit twice)
Ctrl+a
Ctrl+d # delete character at cursor
Ctrl+e
Bksp # delete character left
Ctrl+n
Ctrl+a
Ctrl+k # delete to end of line
Ctrl+k # delete blank line
Alt+d # delete word
Alt+3 Ctrl+f # forward 3 spaces
Ctrl+k # delete to end of line
Ctrl+k # nonblank line not deleted, but line below joined
Alt+2 Ctrl+n # cursor down 2 lines
Ctrl+a
Ctrl+k
Alt+5 Ctrl+n # down 5 lines
Ctrl+k
Alt+5 Ctrl+n
Ctrl+y # yank (paste) last delete
Ctrl+y # yank same delete again
Alt+y # yank previous delete
Alt+20 Ctrl+f # right 20 spaces
Ctrl+Space # (or Ctrl+@ or Alt+x set-mark) set mark
Alt+5 Ctrl+n # down 5 lines
Ctrl+w # delete (cut) from mark to character left of cursor
Alt+<
Ctrl+y # yank last delete
Alt+x set-mark
Alt+5 Ctrl+n
Alt+w # copy from mark to character left of cursor
Ctrl+y # yank last copy
Ctrl+a
Alt+x set-mark
Alt+5 Ctrl+n
Alt+20 Ctrl+f
Ctrl+x Ctrl+x # exchange mark and point
Ctrl+x Ctrl+x
Ctrl+x r k # kill rectangle defined by mark and character left of cursor
Ctrl+x r y # yank rectangle, replacing what you just killed
Alt+5 Ctrl+n
Alt+20 Ctrl+f
Ctrl+x r y # yank rectangle again
Alt+10 Ctrl+n
Ctrl+l # recenter (and redraw) screen
# type the following lines and hit Enter after each:
line one
line two
Insert # (or Alt+x overwrite-mode) overwrite mode
foo # type these characters
Insert # (or Alt+x overwrite-mode) toggle back to insert mode
bar # type these characters
Ctrl+x u # undo
Ctrl+x u # undo again (multi-level)
Alt+<
Alt+x replace-string
: Enter # search string
# Enter # replacement string
Alt+< # move to top of buffer
Alt+x replace-regexp
h$ Enter # search regex
H Enter # replacement string
Alt+<
Ctrl+x ( # start macro definition (double space)
Ctrl+e # end line
Enter # new line
Ctrl+n # next line
Ctrl+x ) # end macro definition
Ctrl+e # execute macro
e # repeat macro
Ctrl+x Ctrl+f group1 # find file (opens new buffer)
Alt+5 Ctrl+k # delete five lines
Ctrl+x b pass1 # switch buffer
Ctrl+y # paste
Ctrl+x Ctrl+f fstab1
Ctrl+k # kill buffer
Ctrl+x 2 # split screen top/bottom
Ctrl+x b pass1 # switch buffer
Ctrl+v # next screen
Ctrl+x o # (lowercase O) other window
Alt+v # previous screen
Ctrl+x 0 # (zero) delete window
Ctrl+x 3 # split screen side-to-side
Ctrl+x b group1 # switch buffer
Ctrl+x o # other window
Ctrl+x 0 # (zero) delete window (1 deletes all other windows)
Ctrl+x Ctrl+q # toggle on
foo # type these characters, all you see is an error message
Ctrl+x Ctrl+q # toggle off
foo # type these characters, OK now
Ctrl+x i group1 # insert file contents
Ctrl+x Ctrl+s # save
Ctrl+x Ctrl+w pass2 # write (save as)
Ctrl+x Ctrl+c # save and exit
rm fstab1 group1 pass1 pass2 # clean up
Ctrl+h t # run within emacs