|
@@ -1,3 +1,4 @@
|
|
|
+
|
|
|
# Emacs Cheatsheet
|
|
|
|
|
|
As a keyboard focused editor, emacs makes text editing efficient with the use of "control characters" like `<RET>`, `<TAB>`, `<DEL>`, `<ESC>`, `<F1>`, `<Home>`, etc. Emacs extends this efficiency by recognizing control characters that are entered using "modifier keys", these keys are `<Ctrl>`, `<Meta>` or `<Alt>`. With these modifier keys you can type chords or "key-chords" which are combinations of key-strokes. Here a “key chord” means two keys pressed simultaneously, or a single key quickly pressed twice. These chords are bind to an emacs command to execute it faster than typing the full command name.
|
|
@@ -7,9 +8,9 @@ These chords are composed of a modifier key and simple characters. For example,
|
|
|
If you see a space inside a chord like this `C-x f`, this means you press and release the chord prefix `C-x` and then type `f`.
|
|
|
|
|
|
|
|
|
-## Getting help in emacs
|
|
|
+## Getting Help In Emacs
|
|
|
|
|
|
-### Basic help commands
|
|
|
+### Basic Help Commands
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
@@ -17,7 +18,7 @@ If you see a space inside a chord like this `C-x f`, this means you press and re
|
|
|
| `C-h ?` | Enter 'metahelp' mode with all available options to get help about everything inside emacs |
|
|
|
|
|
|
|
|
|
-### Commands, keys and functions
|
|
|
+### Commands, Keys And Functions
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
@@ -46,7 +47,7 @@ If you see a space inside a chord like this `C-x f`, this means you press and re
|
|
|
| `C-h S` | Show a description of a symbol in pertinent manual |
|
|
|
|
|
|
|
|
|
-### Other help commands
|
|
|
+### Other Help Commands
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
@@ -59,7 +60,7 @@ If you see a space inside a chord like this `C-x f`, this means you press and re
|
|
|
| `C-h .` | Show local help at point |
|
|
|
|
|
|
|
|
|
-### Miscelaneous help
|
|
|
+### Miscelaneous Help
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
@@ -92,6 +93,8 @@ If you see a space inside a chord like this `C-x f`, this means you press and re
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
|
| `C-x =` | Display a message in echo area, describing the character at point |
|
|
|
+| `M-=` | Display the number of lines, words and characters present in the region |
|
|
|
+| `C-u M-=` | Display the number of lines, words and characters for the entire buffer |
|
|
|
| `C-g` | Signal a ‘quit’ condition. Quits from any operation you want to get out of and cancel it. |
|
|
|
| `C-x C-c` | Kill emacs saving all currently opened files, this will kill the current connection terminating the emacs program |
|
|
|
| `C-z` | If using a text terminal, this suspends Emacs, on GUI this iconifies or minimizes the selected frame |
|
|
@@ -124,7 +127,7 @@ A prefix key combines with the following input event to make a longer key sequen
|
|
|
These commands are the basics for entering text, make corrections and saving the work to files.
|
|
|
|
|
|
|
|
|
-### Inserting text
|
|
|
+### Inserting Text
|
|
|
|
|
|
To insert text in emacs you simply type the associated key with the ordinary "graphic character". This adds the charager to the currently selected buffer at the current point. The insertion moves the cursor one point foward, the point remains just after the inserted text.
|
|
|
|
|
@@ -138,7 +141,7 @@ To insert text in emacs you simply type the associated key with the ordinary "gr
|
|
|
| `C-x 8 <RET>` | Prompts the user to insert the unicode name or code point of a character using the minibuffer |
|
|
|
|
|
|
|
|
|
-### Changing the location of point
|
|
|
+### Changing The Location Of Point
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
@@ -172,19 +175,64 @@ To insert text in emacs you simply type the associated key with the ordinary "gr
|
|
|
| `C-u C-x C-n` | Cancel the goal column, `C-n` and `C-p` preserve the horizontal position as usual |
|
|
|
|
|
|
|
|
|
-### Erasing text
|
|
|
+### Erasing Text
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
|
-| `<BACKSPACE>` | Delete the character before point, or an active region |
|
|
|
-| `<Delete>` | Delete the character after the point, or an active region |
|
|
|
-| `C-d` | Delete the character after point |
|
|
|
+| `<BACKSPACE>`, `<DEL>`, `<--` | Delete the character before point, or an active region |
|
|
|
+| `<Delete>`, `<Supr>` | Delete the character after the point, or an active region |
|
|
|
+| `C-d` | Delete the character after point, regardless of whether the region is active |
|
|
|
| `C-k` | Kill to the end of the line |
|
|
|
| `M-d` | Kill forward to the end of the next word |
|
|
|
| `M-<BACKSPACE>` | Kill back to the beginning of the previous word |
|
|
|
|
|
|
+
|
|
|
### Undoing Changes
|
|
|
|
|
|
| Key/Chord | Action |
|
|
|
| --------- | ------ |
|
|
|
-| `C-/`, `C-x u`, `C-_` | Undo one entry of the undo records |
|
|
|
+| `C-/`, `C-x u`, `C-_` | Undo one entry of the undo records |
|
|
|
+
|
|
|
+
|
|
|
+### Files
|
|
|
+
|
|
|
+Text that you insert in an Emacs buffer lasts only as long as the Emacs session. To keep any text permanently, you must put it in a “file”.
|
|
|
+
|
|
|
+| Key/Chord | Action |
|
|
|
+| --------- | ------ |
|
|
|
+| `C-x C-f` | Prompt the user to type a file name in the minibuffer, it opens the file to visit if exist or creates a new buffer with that name if the file does not exist |
|
|
|
+| `C-x C-r` | Prompt the user to type a file name in the minibuffer, it opens the file to visit without allowing to make changes to it |
|
|
|
+| `C-x C-s` | Copies the altered buffer contents into the named file (if visiting) or prompts the user in the minibuffer to provide a name for a new file in disk |
|
|
|
+
|
|
|
+
|
|
|
+### Blank Lines
|
|
|
+
|
|
|
+Here are special commands and techniques for inserting and deleting
|
|
|
+blank lines.
|
|
|
+
|
|
|
+| Key/Chord | Action |
|
|
|
+| --------- | ------ |
|
|
|
+| `C-o` | Insert a blank line after the cursor (open-line) |
|
|
|
+| `C-x C-o` | Delete all but one of many consecutive blank lines (delete-blank-lines) |
|
|
|
+
|
|
|
+
|
|
|
+### Numeric Arguments
|
|
|
+
|
|
|
+You can provide numeric arguments to commands for repetition count. The easiest way is to type a digit or a minus sign while holding down the <Meta> key. The minus sign is to provide a negative argument.
|
|
|
+
|
|
|
+```
|
|
|
+M-[arg] [command]
|
|
|
+```
|
|
|
+
|
|
|
+| Key/Chord | Action |
|
|
|
+| --------- | ------ |
|
|
|
+| `M-[arg] [command]` | Execute command successively [arg] times |
|
|
|
+| `C-u [arg] [command]` | Execute command successively [arg] times or four times if [arg] is not provided. This also works as a "by four" multiplier |
|
|
|
+
|
|
|
+
|
|
|
+### Repeating a Command
|
|
|
+
|
|
|
+| Key/Chord | Action |
|
|
|
+| --------- | ------ |
|
|
|
+| `C-x z` | Repeats the previous emacs command many times if arg given or using the same arguments used before |
|
|
|
+| `C-x z+` | Repeats the previous emacs command many times if arg given or using the same arguments used before. Each 'z' you type repeats the command one more time (notice the regex +) |
|