Skip to content

Instantly share code, notes, and snippets.

@tacksoo
Forked from rochacbruno/emacs.markdown
Created November 19, 2019 21:30
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 tacksoo/deca8665ff3250acc45b81f7a8973315 to your computer and use it in GitHub Desktop.
Save tacksoo/deca8665ff3250acc45b81f7a8973315 to your computer and use it in GitHub Desktop.
Emacs and Screen commom keys

emacs

basic

C-g = abort command
C-x C-c = Exit
C-_ | C-x u = Undo
C-z = iconify / %emacs to get back
C-x C-z = suspend, back qith "fg"
M-x shell = bash
ESC-! = shell command
C-h b = list of key bindings
M-! = Shell command
M-& = async shell command
M-% = query replace
M-x global-linum-mode = show line numbers

motion

C-f/M-f = right/forward
C-b/M-b = left/backward
C-n = next/down
C-p = previous/open
C-e = forward to end of line
C-a = backward to init of line
C-o = open new line
M-a = sentence forward
M-e = sentence backward
M-> = forward end of file
M-< = backward begin of file
C-v = Page down
M-v = Page up
C-l = recenter
C-M-v = Other window down
M-g g = go to line

Copy Paste

C- SPC = Mark region
C-c l = Mark Line
C-w = Cut
M-w = Copy
C-y = Paste
C-c y = Duplicate line
C-y M-y = Next on clipboard

windows

C-x 0 = close current window
C-x 1 = show only one window
C-x 2 = Split horizontal
C-x 3 = Split vertical
C-x o = Move to other window
C-x 4 f = Open file another window

C-x k bufname - Kill buffer
M-x kill-some-buffers
M-x kill-matching-buffers

tab

C-x left | right
C-x C-left | C-right

files

C-x C-f = Find file or create
C-x C-r = Fine and open read only
C-x C-q = Toggle read only
C-x C-s = Save file
C-x C-w = Write file (save as)
C-x s = save all windows
C-x b | C-x C-b = List windows
C-x d = dired

find / replace

C-s = Find
C-r = Find backward
M-x replace-string
M-x query-replace

delete

M-d = forward one word
M-DEL = backward one word
C-k = to end of line
C-SPC C-a C-w = to start of line

text

C-x C-l = downcase marked region
C-x C-u = uppercade marked region
C-x C-o = delete blank lines
C-x C-p = mark the page
C-x h = mark whole buffer
C-x i = insert external file
C-x l = count lines in page
C-x

C-x 6 2 2C-two-columns C-x 6 b 2C-associate-buffer C-x 6 s 2C-split C-x 6 2C-two-columns

screen

screen -S < name > = start a new session
screen -ls = list sessions
screen -r = attach to a running session
screen -r < name > = attach to named
screen -d < name > = detach running session

windows

C-a d = detach
C-a ? = keybindings
C-a c = Create new window
C-a C-a = FLip windows
C-a n | C-a SPC = next window
C-a p | C-a BKSPC = previous window
C-a " = window list
C-a w = window bar
C-a k = Kill current window
C-a \ = Kill all windows
C-a A = rename current window

#split

C-a S = Split horizontal
C-a | or C-a V = Split Vertical
C-a TAB = Change panel
C-a X = remove current panel
C-a Q = remove all keep current

scrip

screen -S < name > -X < command >

misc

C-a C-l = redraw
C-a [ or C-a ESC = copy mode
C-a ] = paste
C-a x = password protect

tmux - terminal multiplexer

Managing tmux sessions:

$ tmux      # start tmux server
$ tmux at   # attach running sessions to a terminal
$ tmux ls   # list running tmux sessions

Sharing sessions between terminals:

$ tmux new -s session_name # make new named session
$ tmux at -t session_name  # attach to exist session (allowing shared sessions)

Commands (used within a running tmux session):

c  - create new window
n/l - next/last window
&  - kill current window

%  - split window, adding a vertical pane to the right
"  - split window, adding an horizontal pane below
←/→ - move focus to left/right pane
↑/↓ - move focus to upper/lower pane

!  - Break current pane into new window
x  - Kill the current pane.
d  - detach the current client

[  - enter copy mode (then use emacs select/yank keys)
    * press CTRL-SPACE or CTRL-@ to start selecting text
    * move cursor to end of desired text
    * press ALT-w to copy selected text

]  - paste copied text

?  - show tmux key bindings

v - split vertical
h - split horizontal

NOTE:

  • All commands need to be prefixed with the action key.
  • By default, this is CTRL-b
    Ctrl-b c Create new window  
    Ctrl-b d Detach current client  
    Ctrl-b l Move to previously selected window
    Ctrl-b n Move to the next window
    Ctrl-b p Move to the previous window
    Ctrl-b & Kill the current window
    Ctrl-b , Rename the current window
    Ctrl-b % Split the current window into two panes
    Ctrl-b q Show pane numbers (used to switch between panes)
    Ctrl-b o Switch to the next pane
    Ctrl-b ? List all keybindings
    Ctrl-b n (Move to the next window)
    Ctrl-b p (Move to the previous window)
    Ctrl-b l (Move to the previously selected window)
    Ctrl-b w (List all windows / window numbers)
    Ctrl-b <window number> (Move to the specified window number, the default bindings are from 0 – 9)
    Ctrl-b % (Split the window vertically)
    Ctrl-b : “split-window” (Split window horizontally)
    Ctrl-b o (Goto next pane)
    Ctrl-b q (Show pane numbers, when the numbers show up type the key to goto that pane)
    Ctrl-b { (Move the current pane left)
    Ctrl-b } (Move the current pane right)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment