back
a character – C-b
beginning
of line - C-a
beginning of sentence - M-a
—C—
carriage returns, get
rid of – M-^
close a file – control x, control c
cut and paste
1.
Move
the point (the cursor) to the beginning of the region to be moved
2.
Type
C-<space> to set the mark
3.
Move
the point to the end of the region to be moved
4.
Type
C-w to wipe that region into the kill ring
5.
Move
the point to the position where the text should be inserted
6.
Type
C-y to yank the deleted text out of the kill ring, and insert it where the
point is
If the text to be cut and pasted is only one
line long, the process is even easier:
1.
Move
the point to the line to be removed, and type C-a if necessary to move the
point to the beginning of the line
2.
Type
C-k to delete the line
3.
Move
the point to where the line should be pasted
4.
Type
C-y to yank the line into your document
5.
Alternatively,
to insert something from what you put in the buffer BEFORE you started up
emacs, C-insert
In addition, step 2
above can be repeated to cut and paste two or more lines all at once.
copy and paste
The copy and paste process is almost exactly the
same as the cut and paste process. The only difference is use of the M-w (“M”
stands for the “
.emacs
file template
end
of line - C-e
end of sentence - M-e
forward
8 characters – C-u 8 C-f
forward
a character – C-f
front
of line - C-a
frozen – C-g
global
replace
M-x “replace-string”
and hit return
The
prompt will change to: “Replace string:”.
Type in the “search” string and hit return. So type in a string like “foo” and hit return
The
prompt will change to: “Replace string bob with:” Type in a string like “bar” and hit return
You
should get something like: “Replaced 20 occurrences”
html - enhanced HTML editing mode)
download HTML helper mode beta files html-helper-mode.el
and tempo.el
to /usr/local/share/emacs/site-lisp
add some lines to .emacs
(autoload 'html-helper-mode
"html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons
'("\\.htm$" . html-helper-mode) auto-mode-alist))
(setq auto-mode-alist (cons
'("\\.html$" . html-helper-mode) auto-mode-alist))
hung – C-g
—I—
indent the region 4 spaces:
C-u C-x TAB
to indent it -4 spaces:
C-u -4 C-x TAB
or, more simply, mark the corners of the indentation
that you want to remove and use kill-rectangle, which is bound to "C-x r
k" by default.
key,
find the function that's bound to any key with "C-h k", then type the
key you're interested in. It will be
different depending on the Emacs mode you're in.
line
numbers
download setnu.el to
/usr/local/share/emacs/site-lisp
in your .emacs, add the line:
(require 'setnu)
In an emacs session, M-x setnu-mode toggles the line
number mode on and off.
M, as in “M-x”.
You’ll see a lot of this in online explanations of how emacs works. Turns out “M” stands for “the Meta key” which
is usually the “Alt” key (if you keep it pressed down) or the “Esc” key (if you
press and then release before hitting next character) but can apparently be
configured to be some other key.
move
to front or end of line - C-a or C-e
move
to front or end of sentence - M-a or M-e
—O—
outdent – see indent - to outdent 4 spaces, C-u -4 C-x TAB
package – emacs21
print – M-x ps-print-buffer for whole doc, M-x ps-print-region for just a region
replace – In addition to the simple ‘M-x
replace-string’ command which is like that found in most editors, there is a
‘M-x query-replace’ command which finds each occurrence of the pattern and asks
you whether to replace it.
spaces, get rid of – M-x Collapse-spaces.
If this isn’t defined, in your .emacs file,
(defun Collapse-spaces ()
"Turn consecutive spaces and
tabs into one space"
(interactive)
(while (re-search-forward "[
\t]+" nil t)
(replace-match " " nil
nil)))
—T—
tab
key to always insert a tab in perl code
add
this to your .emacs file sometime after the '(load "artselect")' line:
(add-hook 'cperl-mode-hook
(lambda ()
(local-set-key
"\C-i" 'tab-to-tab-stop)))
The
behavior it has otherwise is to insert a tab if you're within a line, but if
you're in the whitespace at the beginning of a line it indents the line.
Each
mode in Emacs tends to define tab somehow, so you have to override it on a
per-mode basis like the above. If you
want to do the same thing in Text mode, you would do the above for
'text-mode-hook.
tutorial
– Ctrl-h t
emacs allows for virtually limitless undo, on typing, simple deleting, and kill ring commands. The undo command is C-_ (while holding down Control, type the underscore character). Notice that this requires use of three keys - control, shift, and the underscore key.
Ctrl-x u might also work
2
sessions – m-x man