MCX1 home MCX2 home Essential Linux commands
Keystroke notation:
C-<another key>: The C specifies the Control key (Ctrl)
in conjunction with another key. For example, C-g indicates
this keystroke sequence: Press the Ctrl key down, and, while holding it
down, tap the g key.
M-<a command>: M indicates the Meta key. To implement this key on
an Intel-based computer, press the Esc key, then press the x
key. On Macintosh machines, there may be an easier way: see if one of the function keys
accomplishes the same task.
Starting, ending, and halting Emacs:
1. Start Emacs from the command line: emacs
2. Start Emacs from the command line with file to be edited: emacs
filename
(where filename is file to be edited.)
3. Quit emacs: C-x C-c (While pressing CTRL,
tap the x key, then tap the c key.)
4. Suspend Emacs temporarily: C-z (To return to Emacs,
enter fg from command line.)
Abort and undo commands:
(These are really important! Learn them as soon as possible.)
Abort operation: C-g
Undo an unwanted editing change: C-x u (While pressing CTRL,
tap the x key. Release CTRL and press u)
File commands:
Open file for editing: C-x C-f (f
for file)
Save file: C-x C-s (s for
save)
Write (save) to a different file: C-x C-w (w for
write)
Insert a different file into current file: C-x i
Cursor movement:
To beginning of line: C-a (Use this if the Home
key doesn't work.)
To end of line: C-e (Use this if the End
key doesn't work.)
To right (one character): C-f
To left (one character): C-b
C-p
To previous line: C-p
|
To next line: C-n
C-b ----- C-f
To beginning of file: M-<
|
To end of file: M->
C-n
Deletion commands:
Delete character at cursor: C-d
Delete character left of cursor: Delete key (Note: The BackSpace
brings up the Emacs Help screen
on many systems.)
Delete from cursor to the end of the line: C-k
(This is usually called the kill command)
Write (at cursor) last region deleted: C-y (This is usually
called the yank command.)
Block commands:
Kill a region:
1. Move cursor to beginning of region and type:
C-Space (The set mark
here command)
2. Move cursor to the end of the region and type: C-w (The
kill region command)
Copy a region:
1. Move cursor to beginning of region and type: C-Space (The set mark here command)
2. Move cursor to the end of the region and type: M-w (The
copy to kill ring command)
3. Move cursor to desired copy location and type: C-y (The
yank command)
Window commands:
Delete all other windows: C-x 1 (The
last keystroke is the digit one)
Delete current window: C-x 0 (The last keystroke
is the digit zero)
Switch cursor to other window: C-x o (The last keystroke is a
lower case O)
Searching:
To search forward:
1. Type C-s (The search
forward command). This triggers a prompt for keyboard input.
2. When prompted, start entering the text for which you're searching
3. Use C-s again to repeat the search.
To search backward:
Use the search forward procedure
given above, substituting C-r for C-s
Replacing text:
1. Type M-x replace-string. This
triggers two prompts for keyboard input.
2. Respond to the first prompt by specifying the text
to be replaced.
3. Respond to the second prompt by specifying the text
that will replace the old text.
List files (in current
directory): ls
1. list all files whose names begin with a capital P: ls P*
2. list all files: ls a
3. list all files whose first two characters are numbers: [0-9][0-9]*
Symbolic
names for directories:
1. home directory: ~ EXAMPLE: ls ~/subName lists the files in subdirectory subName
2. parent of current directory: .. EXAMPLE: ls ../sibDirectory lists files in sibling
of current directory
3. current directory: . EXAMPLE: cp DirName/fileA . copies fileA from DirName to current directory
Change
directory: cd directoryName
1. change to parent of current directory: cd ..
2. change to home directory: cd
3. change to a subdirectory of home (from home): cd directoryName
4. change to a subdirectory of home (not from home): cd ~/directoryName
Copy
file: cp sourceName targetName
1. copy from current directory to different directory: cp sourceName
targetDirectory
2. copy from different directory to current directory: cp
targetDirectory/sourceName .
Note: The dot indicates current directory
Deleting
and moving files:
1. delete file: rm fileName
2. move file (this is a destructive command): mv sourceName targetName
Other
directory commands:
1. print working directory: pwd
2. make directory: mkdir newDirectoryName
2. remove directory: rmdir DirectoryName
MCX1 home MCX2 home Essential Emacs commands