Deleting Text
<delete> <backspace> or
whichever is mapped delete prev. char
C-d delete current
character
M-<delete>
one word backwards
M-d one word
forwards
C-k deletes to end
of line
C-k
C-k deletes to end of line and end-of-line
character
M-#
C-k M-# is a general multiplier so will
cause the
deletion to the end of the current line and a
number of lines after
i.e. M-2 C-k deletes to the end of the current line
and the one line after
"kill-ring" = vi's pasting buffer except multiple sequential deletions
collected
no single character deletions are kept
keeps those which have "kill" in the
name of the command
"yank" = vi's "paste"
C-y allows you to bring the most recent
thing out of the
pasting buffer
M-y allows you to go to the previous one
Using Blocking to delete or put into the kill ring
-----------------------------------------------
C-@ sets a marker to indicate the beginning of a block
often mapped also to C-<space>
C-x C-x to see where the marker is set and then to go back to the other end
C-w kill the block (delete from buffer and put into kill ring)
M-w copy the block into the kill ring without modifying the buffer
Undo
----
C-_ or C-x u
undoes the one last change to the work buffer
if repeated continues going back until nothing to undo
M-x revert-buffer allows you to get back the buffer
as it was when you
last saved the file - will make sure
of the file name associated with the buffer
=====================
Shell commands
--------------
M-! command allows
you to do one shell command
opens a new window for the output of that command
use C-x
o to go into that
window
or C-x
1 to get rid of
that window
C-u M-! command puts output into the
current work buffer
---------
M-| command allows
you to act on the marked portions such as find
misspelled words
C-u M-| command allows you to replace that
portion of the document
such as C-u M-| sort
-------------
Interactive shell
M-x shell
starts the interactive shell in a new buffer so you
can then use C-x b to switch into it when ever needed
terminal type is "emacs"
searching
-----------
C-s
string
isearch-forward incremental search
searching for regular expressions
-----------------------------------
M-x isearch-forward-regexp
M-x re-search-forward
regular expression allows these
meta-characters
^ - beginning of line
$ - end of line
. - one character
* - multiple occurrences of character before
[ ] - contain a class of characters
replacing
-----------
interactive replace
----------------------
M-% oldstring <return> newstring
<return>
answer with y - yes,
replace this one, but go on
n - no, do not replace this one, but go on
q - no, do not replace this one, and quit now
! - yes, do replace this one and all others that follow
global replace
------------------
M-x replace-string <return> oldstring
<return> newstring <return>
replace with regular expressions in the search string
---------------------------------------------------------
M-x replace-regexp <return> oldstring
<return> newstring <return>
spelling
--------
can use the regular shell command
C-@ to set the mark
M-| spell to run the spell utility on the marked region
but this has
limitations such as what is used as the dictionary
Emacs speller -
M-x spell-buffer to look through the whole buffer
showing misspelled words
personalize the speller with the .spell file
the .spell file can hold your own words - then
set up Emacs
to use that file with the set up command
(setq spell-command "spell +.spell")
tells it to use the standard shell dictionary
plus the extra
words in the .spell file
.spell must have a blank line at the end
Setting up Emacs
------------------
in file named .emacs or after M-x
general form in .emacs file
(setq variablename value)
general form in session is
M-x set-variable <return>
variablename <return>
value <return>
value is t for on, nil for off or a
specified numeric or string value
common variables and their default values
kill-ring-max 10
window-min-height 3
tab-width
7
case-fold-search t
auto-save-default t
auto-save-interval 100
fill-column 70
modes of operation
M-x auto-fill-mode to turn on the
ability to do filling
(auto line wrap)
Major
Modes Minor Modes
------------ -----------
Fundamental Fill
mode
text
mode
abbrev mode
C
autosave mode
LaTeX
picture
(setq default-major-mode
'text-mode)
or
M-x text-mode
(setq text-mode-hook
'turn-on-auto-fill)
or
M-x auto-fill-mode
-----------------------------------------------------------
Binding Keys
(global-set-key "\M- "
'set-mark-command)
or
M-x global-set-key
<return> <escape>-<space> set-mark-command
(global-set-key
"\M-h" 'hanoi)
or
M-x global-set-key
<return> <escape>-h hanoi
Picture Drawing
-----------------
M-x picture-mode
to go into picture mode
to draw a line
C-c direction
direction =
^ up
` up and left
' up and right
< left
> right
/ down and left
\ down and right
. down
other special picture mode commands
C-d deletes the
contents of a character space
C-c C-d deletes the character space itself
C-k deletes
contents of the current line
<return> moves cursor down
C-b inserts a
blank line