Skip to content

Instantly share code, notes, and snippets.

@bdargan
Last active December 23, 2015 21:09
Show Gist options
  • Select an option

  • Save bdargan/6694851 to your computer and use it in GitHub Desktop.

Select an option

Save bdargan/6694851 to your computer and use it in GitHub Desktop.
emacs bindings i need to learn

Movement / Navigation

forward char/word : C-f, M-f

back char/word : C-b, M-b

next logical line : C-n, M-n

previous line : C-p

  • sometimes, C-p is previous command

page forwards : C-v

page backwards : M-v

previous buffer : C-X <-

buffer start :

buffer end :

previous logical line : C-p

go to line : M-g M-g

jump to file / file or symbol jumping : ?

parens

navigate to end of list/parens : C-M-N

navigate to start of list/parens : C-M-p

Search

search : C-s

search backward : C-r

go to char on this line: M-x iy-go-to-char

search buffers and output result to a new buffer: M-x multi-occur

Replace

search and replace : M-% term, replace

  • replace all with !
  • search term : C-S
  • replace this and find next : SPC

Selection

start highlight a region : C-SPC

select all : C-x h

expand region : ?

multi cursor : M-x mc/mark-next-like-this

Editing

delete forward word : M-d

lowercase : M-l

uppercase : M-u

copy : M-w

cut : C-w

yank : C-y

kill to end of line : C-k

kill paragraph : M-k

undo / redo : C-_ / M-_

indent : ?

Transpose

transpose char/word : C-t, M-t

transpose line : C-x C-t

Rectangles - columns

mark a rectangle : C-x r t

commenting

comment region : M-;

yas/snippets

Keyboard macro

start-record, end record : F3, F4

exececute 9 times : C-9

execute last command : C-p

universal command 4 : C-u 4

Buffers and Files

other buffer : C-x o

list all : C-X b

Find File : C-X C-f

Quit : C-x C-c

Shell

run command and output to buffer : C-u M-|

pretty print json : C-u M-| python -m json.tool

Emacs configuration and setup

Global Key bindings : C-x C-h

all minor modes : C-h m

cancel command : C-g

elisp

evaluate elisp (eval-last-sexp): C-x C-e

list all functions? does the M-x I assume the M-x list gives me all of them?

describe-function to see the inline doc of format-time-string M-x describe-function

Issues with my config

what is the hyper key?

how to get multiple cursors working

auto preview, is that C-c s

emacsrocks

these are from emacsrocks, but my keys aren't mapped that way.

F3 kmacro-start-macro Record your keyboard input to play it back later.

C-9 digit-argument Execute the following command 9 times.

Move point to next occurrence of char. Can start typing immediately : M-m iy-go-to-char

Convert following word to lower case, moving over. : M-l downcase-word

editors and environments

Meta, Super and Hyper mapping

Keyboard bindings and modes

C-h m : show all minor modes for this buffer

http://stackoverflow.com/questions/162896/emacs-on-mac-os-x-leopard-key-bindings

OSX

Meta (ESC) : iTerm2 edit prefs > Keys, set left option key as Meta by selecting +Esc

Super (Super) : (setq mac-option-modifier 'super)

Hyper () : fn

Linux (ubuntu 12.04)

C- Control M- Meta (ESC) : terminal prefs. Edit > Keyboard Shortcuts. Disable menu access keys S- Super: is Win key by default. use compviz configuration manager to remove system shortcuts that capture your combination Fn? Hyper: Dash keyboard Layout to mod keys, capslock for ctrl, Alt mapped to Win key, Meta mapped to Menu key. refer: http://www.tonyballantyne.com/tech/ubuntu-emacs-org-mode-setup/

Blockers

multiple-cursor mode, uses C-S-c and H-SPC. no other bindings in live pack use hyper key. super key isn't defined. M-x mc/mark-next-like-this

Modes

magit

add untracked file/all files: s / S

unstage file/all files: u / U

show : M-s

hide M-h

commit : c

save commit msg : C-c C-c

push : p p

Projectile-mode

Keybinding Description C-c p f Display a list of all files in the project. With a prefix argument it will clear the cache first. C-c p d Display a list of all directories in the project. With a prefix argument it will clear the cache first. C-c p T Display a list of all test files(specs, features, etc) in the project. C-c p l Display a list of all files in a directory (that's not necessarily a project) C-c p g Run grep on the files in the project. C-c p b Display a list of all project buffers currently open. C-c p o Runs multi-occur on all project buffers currently open. C-c p r Runs interactive query-replace on all files in the projects. C-c p i Invalidates the project cache (if existing). C-c p R Regenerates the projects TAGS file. C-c p k Kills all project buffers. C-c p D Opens the root of the project in dired. C-c p e Shows a list of recently visited project files. C-c p a Runs ack on the project. Requires the presence of ack-and-a-half. C-c p c Runs a standard compilation command for your type of project. C-c p p Runs a standard test command for your type of project. C-c p z Adds the currently visited to the cache. C-c p s Display a list of known projects you can switch to. If you ever forget any of Projectile's keybindings just do a:

C-c p C-h

Org-mode

Global Todo List: M-x org-todo-list

Adding new packages to the .emacs.d

code can be pulled the site-lisp contains other git submodules directly

OR

add package-name to the init.el, which installs from MELPA working-dir in ./emacs.d/elpa

Debug/Dev changes by:

or manually, fork and include in

Refererences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment