Skip to content

Instantly share code, notes, and snippets.

@franee
Last active September 11, 2020 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franee/5d188ce36f6c24181707907614d2c52d to your computer and use it in GitHub Desktop.
Save franee/5d188ce36f6c24181707907614d2c52d to your computer and use it in GitHub Desktop.
everyday emacs commands
# start / exit / suspend
emacs -nw - start emacs in terminal
C-x C-x - exit
C-z - suspend
# file navigation
C-x C-f - find then load file
C-x C-s - save file
C-x C-v - reload file
C-x k - close file
C-x b - switch to other open file (buffer)
M-x nuke-all-buffers - close all open files
# search
C-s - search forward within file / move to next occurrence of search results
C-r - search backward within file / move to previous occurrence of search results
M-x rgrep - search across files
M-x replace-string - search & replace
# navigation
C-f - forward 1 character
C-b - backward 1 character
M-f - forward 1 word
M-b - backward 1 word
C-n - next line
C-p - previous line
C-v - page down
M-v - page up
C-l - set line (where cursor is) to be in the middle of the screen. Cycle middle-top-bottom by pressing multiple times.
# windows
C-x 1 - close other windows except the selected one
C-x 2 - split the selected window horizontally
C-x 3 - split the selected window vertically
C-x o - cycle through windows
C-x + - balance windows (same as M-x balance-windows)
# marking
C-space - set a mark (then do navigation to set the end of block)
C-w - cut (after a block has been marked)
M-w - copy (after a block has been marked)
C-y - paste (after a block has been marked)
M- ; - comment-out a region (after a block has been marked)
C-M-\ - auto-indent a region (after a block has been marked)
# misc
C-k - delete a line
C-x u - undo a change
M-x align-regexp - align text based on regex (mark a region first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment