~ read.

Linux 下编辑器eMacs -- 之 -- Emacs Commands List

C = Control
M = Meta = Alt|Esc

Basics
C-x C-f“find” file i.e. open/create a file in buffer
C-x C-ssave the file
C-x C-wwrite the text to an alternate name
C-x C-vfind alternate file
C-x iinsert file at cursor position
C-x bcreate/switch buffers
C-x C-bshow buffer list
C-x kkill buffer
C-zsuspend emacs
C-X C-cclose down emacs

Basic movement
C-fforward char
C-bbackward char
C-pprevious line
C-nnext line
M-fforward one word
M-bbackward one word
C-abeginning of line
C-eend of line
C-vone page up
M-vscroll down one page
M-<beginning of text
M->end of text

Editing
M-nrepeat the following command n times
C-urepeat the following command 4 times
C-u nrepeat n times
C-ddelete a char
M-ddelete word
M-Deldelete word backwards
C-kkill line

C-SpaceSet beginning mark (for region marking for example)
C-W“kill” (delete) the marked region region
M-Wcopy the marked region
C-y“yank” (paste) the copied/killed region/line
M-yyank earlier text (cycle through kill buffer)
C-x C-xexchange cursor and mark

C-ttranspose two chars
M-ttranspose two words
C-x C-ttranspose lines
M-umake letters uppercase in word from cursor position to end
M-csimply make first letter in word uppercase
M-lopposite to M-u

Important
C-gquit the running/entered command
C-x uundo previous action
M-x revert-buffer RETURN(insert like this) undo all changes since last save
M-x recover-file RETURNRecover text from an autosave-file
M-x recover-session RETURNif you edited several files

Online-Help
C-h cwhich command does this keystroke invoke
C-h kwhich command does this keystroke invoke and what does it do?
C-h lwhat were my last 100 typed keys
C-h wwhat key-combo does this command have?
C-h fwhat does this function do
C-h vwhat’s this variable and what is it’s value
C-h bshow all keycommands for this buffer
C-h tstart the emacs tutorial
C-h istart the info reader
C-h C-kstart up info reader and go to a certain key-combo point
C-h Fshow the emacs FAQ
C-h pshow infos about the Elisp package on this machine

Search/Replace
C-sSearch forward
C-rsearch backward
C-greturn to where search started (if you are still in search mode)
M-%query replace

Space or yreplace this occurence
Del or ndon’t replace
.only replace this and exit (replace)
,replace and pause (resume with Space or y)
!replace all following occurences
^back to previous match
RETURN or qquit replace

Search/Replace with regular expressions
Characters to use in regular expressions:
^beginning of line
$end of line
.single char
.*group or null of chars
\<beginning of a word
\>end of a word
[]every char inside the backets (for example [a-z] means every small letter)

M C-s RETURNsearch for regular expression forward
M C-r RETURNsearch for regular expression backward
M C-sincremental search
C-srepeat incremental search
M C-rincremental search backwards
C-rrepeat backwards
M-x query-replace-regexpsearch and replace

Window-Commands
C-x 2split window vertically
C-x ochange to other window
C-x 0delete window
C-x 1close all windows except the one the cursors in
C-x ^enlarge window
M-x shrink-windowcommand says it ;-)
M C-vscroll other window
C-x 4 ffind file in other window
C-x 4 ochange to other window
C-x 4 0kill buffer and window
C-x 5 2make new frame
C-x 5 ffind file in other frame
C-x 5 ochange to other frame
C-x 5 0close this frame

Bookmark commands
C-x r mset a bookmark at current cursor pos
C-x r bjump to bookmark
M-x bookmark-renamesays it
M-x bookmark-delete
M-x bookmark-save ”
C-x r llist bookmarks

dmark bookmark for deletion
rrename bookmark
ssave all listed bookmarks
fshow bookmark the cursor is over
mmark bookmarks to be shown in multiple window
vshow marked bookmarks (or the one the cursor is over)
ttoggle listing of the corresponding paths
w” path to this file
xdelete marked bookmarks
Del?
qquit bookmark list

M-x bookmark-writewrite all bookmarks in given file
M-x bookmark-loadload bookmark from given file

Shell
M-x shellstarts shell modus
C-c C-csame as C-c under unix (stop running job)
C-ddelete char forward
C-c C-dSend EOF
C-c C-zsuspend job (C-z under unix)
M-pshow previous commands

DIRectory EDitor (dired)
C-x dstart up dired
C(large C) copy
dmark for erase
Ddelete right away
e or fopen file or directory
greread directory structure from file
Gchange group permissions (chgrp)
kdelete line from listing on screen (don’t actually delete)
mmark with *
nmove to next line
oopen file in other window and go there
C-oopen file in other window but don’t change there
Pprint file
qquit dired
Qdo query-replace in marked files
Rrename file
uremove mark
vview file content
xdelete files marked with D
zcompress file
M-Delremove all marks (whatever kind)
~mark backup files (name~ files) for deletion
#mark auto-save files (#name#) for deletion
*/mark directory with * (C-u * removes that mark again)
=compare this file with marked file
M-=compare this file with it’s backup file
!apply shell command to this file
M-}change to the next file marked with * od D
M-{” previous ”
% dmark files described through regular expression for deletion
% m” (with *)
+create directory
>changed to next dir
<change to previous dir
stoggle between sorting by name or date

Maybe into this category also fits this command:
M-x speedbarstarts up a separate window with a directory view

Telnet
M-x telnetstarts up telnet-modus
C-deither delete char or send EOF
C-c C-cstop running job (similar to C-c under unix)
C-c C-dsend EOF
C-c C-oclear output of last command
C-c C-zsuspend execution of command
C-c C-ukill line backwards
M-precall previous command

Text
Works only in text mode
M-scenter line
M-Scenter paragraph
M-x center-regionname says

Macro-commands
C-x (start macro definition
C-x )end of macro definition
C-x eexecute last definied macro
M-n C-x eexecute last defined macro n times
M-x name-last-kbd-macrogive name to macro (for saving)
M-x insert-keyboard-macrosave named macro into file
M-x load-fileload macro
M-x macronameexecute macroname

Programming
M C-\indent region between cursor and mark
M-mmove to first (non-space) char in this line
M-^attach this line to previous
M-;formatize and indent comment
C, C++ and Java Modes
M-abeginning of statement
M-eend of statement
M C-abeginning of function
M C-eend of function
C-c RETURNSet cursor to beginning of function and mark at the end
C-c C-qindent the whole function according to indention style
C-c C-atoggle modus in which after electric signs (like {}:';./*) emacs does the indention
C-c C-dtoggle auto hungry mode in which emacs deletes groups of spaces with one del-press
C-c C-ugo to beginning of this preprocessor statement
C-c C-ccomment out marked area
More general (I guess)
M-x outline-minor-modecollapses function definitions in a file to a mere {…}
M-x show-subtreeIf you are in one of the collapsed functions, this un-collapses it
In order to achive some of the feats coming up now you have to run etags *.c *.h *.cpp (or what ever ending you source files have) in the source directory
M-.(Thats Meta dot) If you are in a function call, this will take you to it’s definition
M-x tags-search ENTERSearches through all you etaged
M-,(Meta comma) jumps to the next occurence for tags-search
M-x tags-query-replaceyum. This lets you replace some text in all the tagged files
``

GDB (Debugger)
M-x gdbstarts up gdm in an extra window

Version Control
C-x v dshow all registered files in this dir
C-x v =show diff between versions
C-x v uremove all changes since last checkin
C-x v ~show certain version in different window
C-x v lprint log
C-x v imark file for version control add
C-x v hinsert version control header into file
C-x v rcheck out named snapshot
C-x v screate named snapshot
C-x v acreate changelog file in gnu-style

comments powered by Disqus