Binding | Meaning |
---|---|
Exiting Emacs | |
C-x C-c (hold down Control and hit X, then keep Control pressed down and hit C) | Exit Emacs |
C-x C-c then d when given options | Will diff the current buffer against the backing filesystem file to see if the changes are what you want |
C-x C-c then ! when given options | Will save all open unsaved buffers, then exit Emacs |
Oops | |
C-g | Oops. Exit out of whatever Emacs commands I was currently doing, without making changes. Doesn't exit Emacs, but exits any current actions. Hit multiple times if needed to get back to simple editing. |
Files | |
C-x C-f and C-x C-r | Opens a file for editing (C-x C-f) or in read-only mode (C-x C-r) |
C-x d | Enter dired mode. So many options in dired (be careful). Once in, Enter will open the file or directory in a new buffer. ^ will go up a directory level. q will quit dired mode. n & p go up & down, along with the arrow keys. |
Movement | |
C-v and M-v | Scroll down (C-v) or up (M-v) a screen |
C-x < or C-x > | Scroll left (C-x <) or right (C-x >) a screen |
M-< or M-> | Move to beginning (M-<) or end (M->) of the buffer (after, you can type C-u C-Space to return to earlier mark) |
M-m | Move to first non-whitespace character on the line |
M-e or M-a | Move up or down by sentences |
C-l | Locate the current line to other locations - top, middle, bottom will rotate through |
M-r | Cycle through top/middle/bottom for the point. |
C-M-l | Re-position so the comment or definition is fully in view in the buffer (or as much as is possible). |
C-M-f or C-M-b | Move forward by expression |
C-M-a or C-M-e | Move to beginning (a) or end (e) of function |
C-M-d and C-M-u | Move to the next function call in depth (d), or back up out of the function (u) (will also do the same for strings) |
M-e (when in the isearch context) | Edit the search string in the minibuffer, then ENTER to return to searching |
C-s | Incremental search |
C-M-s | Regex-aware isearch |
M-s w | isearch-forward-word |
C-s C-s | Repeat last isearch |
C-x C-n (and later C-u C-x C-n to disable) | Goal column mode (to move to the same column as you move lines) |
M-g g (or M-g M-g) # | Go to line # |
M-{ and M-} | Move forward to end of paragraph (or backward to start of paragraph) |
C-x left/right-arrow | Switch tabs when in global-tab-line-mode |
C-M-S-v | Scroll up on other window (presumably in multi-window mode) |
C-M-n or C-M-p | Go to next list expression (n) or previous (p) |
Editing | |
C-/ | Undo changes (same as C-x u) |
C-M-\ | Indents a region using the major mode's region indent command |
C-x Tab | Rigidly indents a region |
M-i | Inserts spaces or tabs (as appropriate) to the next tab stop |
M-z | Kill to a specific character (only one, prompted) |
C-d or M-d | Delete character (C-d) or word (M-d) at point |
C-k | Kill rest of the line from the point |
C-Space | Set the mark to start a selection for a region. Usually used in conjunction with C-w or M-w to cut or copy once you've gotten to the end of the region. |
C-w | Kill the selection (equivalent to Cut) |
C-h v kill-ring | See the contents of the kill ring |
M-w | Copy the selection (send it to the kill ring, but leave it in place) |
C-y | Yank from the kill ring (equivalent to Paste) |
M-y | Cycle through the kill ring, replacing yanked text (used after C-y) |
C-M-k | Kill to the end of the s-expression |
M-h | Marks the next paragraph |
C-x h | Mark the entire buffer |
C-M-h | Mark the next function |
C-M-Space | Mark the next s-expression |
M-& | Mark the next word |
C-t or M-t | Transpose character (C-t) or words (M-t) |
C-x C-u or C-x C-l | Upper or lowercases the region. |
M-c or M-u or M-l | Capitalizes, upper cases, or lower cases the next word |
Searching | |
C-s and C-M-s | Incremental search (C-s) or regex search (C-M-s). Do C-s twice to re-do the last incremental search. (default is case-insensitive until you type an upper-case character) Once in search mode, you can use M-n and M-p to cycle through prior search history. You can also use C-w to take the word at point as the search term, or C-y to yank to the search term. |
C-r and C-M-r | Backward incremental search (C-r) or regex search (C-M-r) |
M-% or C-M-% | Normal (M-%) or Regexp (C-M-%) search & replace (can also access from inside incremental search) |
M-s o | Occur mode - show (in a separate buffer) the lines & line numbers that match the search expression. You can then edit them with "e", and use C-c C-c to commit the changes. |
Describe / help | |
F10 | Open/close menu bar |
C-h C Enter | Show encoding information about the current buffer |
C-h a | Describe the apropos command (followed by search term) |
C-h m | Describe the current major mode |
C-h f | Describe a function |
C-h v | Describe a variable |
C-h k | Describe a keybinding |
earlier keybinding + Ctrl-h | Get help with possible options for the earlier keybinding |
Code-related | |
M-; | Comment/uncomment marked area |
M-x compile and M-x recompile and C-x p c | Compile code (with M-x compile, it will ask for a compilation command), and recompile (M-x recompile will re-run the last compile command). Within that, M-g M-n, M-g M-p will take you to previous/next error. C-x p c will compile in the current project. |
M-x hexl-mode | Switch to hex editor viewing mode for existing buffer |
C-x x | Start eLisp debugger |
M-. | eglot mode: Find definition of the function under point. (requires xref) Use M-, to return. |
M-? | Find references matching a pattern |
C-M-i | eglot mode: Completion at point. |
M-x eglot-rename | eglot mode: Rename the symbol at point (across the file?/project?) |
M-? | eglot mode: Find references that call the function at point. |
Helm Mode | |
Enter | Primary action |
C-e | Secondary action |
C-j | Tertiary action |
Tab | Switch to action selector |
C-x c r | Interactive regular expression builder |
Macros | |
F3 and F4 | Start / stop macro recording, and F4 also plays the last macro |
External (to Emacs) shells | |
M-! | Run command (to be entered in mini-buffer) in a shell, and return the output (if it's one line, it may come back in the mini-buffer, otherwise the output will show in a new buffer) |
M-x shell | Run a shell in an emacs window |
C-x C-f "/ssh:<user>@<host>:<path>" | Will open the file from a remote computer via SSH. Authentication will be triggered after the second ":", and since a path hasn't been entered yet, when you complete authentication, you may end up with a "No file notification program found on ..." error message.. just start typing the path, and it'll disappear. |
C-x C-f "/su:<user>@localhost:<path>" | Will open the file as the user (not your own, normal user). Again, authentication will be triggered after the second ":", and since a path hasn't been entered yet, when you complete authentication, you may end up with a "No file notification program found on ..." error message.. just start typing the path, and it'll disappear. |
Org Mode | |
Tab (on a given indent level) | Collapse visibility for this specific level (take all the levels underneath and don't show them and/or start showing them again). Can be used multiple times to get more/less collapsing (2x to get full) |
S-Tab | Collapse/expand visibility globally. Can be used multiple times to get more/less collapsing (2x to get full) |
M-left/right arrow keys | Change indent level for everything under the current point (including text, but not including lower levels of indent?) |
M-up/down arrow keys | Move indented text up/down iwithin a level |
C-c C-w | Move an item to another item (then opens a search interface to move it to) |
M-Enter | Create a new row at the same indent level as the prior row (headline or non-headline) |
S-right arrow | Cycle through none/TODO/DONE status states for a given item |
C-c C-c | Activate Org Mode's macro reading of start-of-file config information (things like #+SEQ_TODO) |
C-c C-t | Get a menu of all keywords (e.g., for status values if they were custom-configured) |
C-c C-s | Pop up a scheduling calendar to select a date, after which a new Scheduled item will be added. Can edit to add hours after the date if needed. |
C-c C-d | Pop up a scheduling calendar to select a date, after which a new Deadline item will be added |
M-x org-agenda | Open agenda command view |
M-x org-agenda-list | Open agenda view for current week or day (press "q" to exit agenda mode back to editor mode) |
S-f (inside agenda view) | Activate follow mode, which will then show in the editor view the details for the corresponding agenda-view item that's selected |
f or b (inside agenda view) | Move forward/backward in time (next week / day) |
Editing dates in org mode |
Can add edit the date to add timestamps in "16:00-17:00" fashion Can add " +1w" to make it repeat once next week (d=day, w=week, m=month, y=year) " ++1w" to make it start repeating 2 weeks from now? repeat weekly indefinitely? " .+4w" will make it recur 4 weeks after the prior completion |
Checklist mode |
Add a new line (NOT a headline), and start it with "- [ ] " and then name it, to start a checklist. To toggle the checklist item, type C-c C-c To add a checklist summary to the parent level, go to the end of the parent and type either "[/]" or "[%]" and then hit C-c C-c to activate |