Category: Cheat sheets

tmux Help

Back to Cheat Sheets Index

Back to Top

tmux help

Select excerpts from man, windows & panes using vi-mode and my tmux.conf file

Tmux Cheat Sheet
Table of Contents
  1. tmux Configuration
  2. Commands
  3. Windows & Panes
tmux Configuration

Following commands are derived from my tmux.conf. bind-key is mapped as Ctrl+Shift+Z

  1. Create pane
  2. Pane switching
  3. Resize Pane
  4. Window switching
  5. Copy & Paste

Create pane

Ctrl+Shift+Z vSplit Window Vertically
Ctrl+Shift+Z hSplit Window Horizontally

Pane switching

Ctrl+Shift+Z h or Alt+h or Alt+LeftFocus on pane left
Ctrl+Shift+Z j or Alt+j or Alt+DownFocus on pane below
Ctrl+Shift+Z k or Alt+k or Alt+UpFocus on pane above
Ctrl+Shift+Z l or Alt+l or Alt+RightFocus on pane right

Resize Pane

Ctrl+Shift+Z JDecrease Pane 5 lines
Ctrl+Shift+Z KIncrease Pane 5 lines
Ctrl+Shift+Z HDecrease Pane 5 columns
Ctrl+Shift+Z LIncrease Pane 5 columns

Window switching

Shift+RightNext Window
Shift+LeftPrevious Window

Copy & Paste

Initiate block copy mode with Ctrl+Shift+Z [
Use arrow keys to move around the shell window to perform the following.

Ctr+Shift+Z vbegin selection, enter visual mode
Ctr+Shift+Z yyank (copy) selection to buffer

After yanking the selection to the buffer and returning to the command prompt can copy from tmux buffer to system clipboard

Ctr+Shift+Z ycopy from buffer to clipboard
Shift+Insertcopy from clipboard to command line
Commands
C-bSend the prefix key (C-b) through to the application.
C-oRotate the panes in the current window forwards.
C-zSuspend the tmux client.
!Break the current pane out of the window.
"Split the current pane into two, top and bottom.
#List all paste buffers.
$Rename the current session.
%Split the current pane into two, left and right.
&Kill the current window.
'Prompt for a window index to select.
,Rename the current window.
-Delete the most recently copied buffer of text.
.Prompt for an index to move the current window.
0 to 9Select windows 0 to 9.
:Enter the tmux command prompt.
;Move to the previously active pane.
=Choose which buffer to paste interactively from a list.
?List all key bindings.
DChoose a client to detach.
[Enter copy mode to copy text or view the history.
]Paste the most recently copied buffer of text.
cCreate a new window.
dDetach the current client.
fPrompt to search for text in open windows.
iDisplay some information about the current window.
lMove to the previously selected window.
nChange to the next window.
oSelect the next pane in the current window.
pChange to the previous window.
qBriefly display pane indexes.
rForce redraw of the attached client.
sSelect a new session for the attached client interactively.
LSwitch the attached client back to the last session.
tShow the time.
wChoose the current window interactively.
xKill the current pane.
{Swap the current pane with the previous pane.
}Swap the current pane with the next pane.
~Show previous messages from tmux, if any.
Page UpEnter copy mode and scroll one page up.
Up, Down, Left, RightChange to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
M-nMove to the next window with a bell or activity marker.
M-oRotate the panes in the current window backwards.
M-pMove to the previous window with a bell or activity marker.
C-Up, C-Down, C-Left, C-RightResize the current pane in steps of one cell.
M-Up, M-Down, M-Left, M-RightResize the current pane in steps of five cells.
Windows & Panes
^Back to indentation
GBottom of history
EscapeClear selection
EnterCopy selection
jCursor down
hCursor left
lCursor right
LCursor to bottom line
MCursor to middle line
HCursor to top line
kCursor up
dDelete entire line
DDelete/Copy to end of line
$End of line
:Go to line
C-dHalf page down
C-uHalf page up
fJump forward
tJump to forward
FJump backward
TJump to backward
;Jump again
,Jump again in reverse
C-fNext page
WNext space
ENext space, end of word
wNext word
eNext word end
pPaste buffer
C-bPrevious page
bPrevious word
BPrevious space
qQuit mode
vRectangle toggle
C-Down or C-eScroll down
C-Up or C-yScroll up
nSearch again
NSearch again in reverse
?Search backward
/Search forward
0Start of line
SpaceStart selection
gTop of history

Vim Cheat Sheet

Back to Top
Vim Cheat Sheet
Table of Contents
  1. Ctrl+W Assignments
  2. Leader Assignments
  3. Keyboard Shortcuts
  4. Cursor Movement
  5. Insert Mode - ways to commence editing
  6. Editing
  7. NERDtree
  8. Working with Multiple Files
  9. Tabs
  10. Marking text (visual mode)
  11. Visual Commands
  12. Marks
  13. Cut and Paste
  14. Registers
  15. Search & Replace
  16. Environment/Interface
  17. Exiting
Ctrl+W Assignments

For an exhaustive list of all Ctrl+W syntax, click Vim documentation: windows

Ctrl+W +/-increase/decrease window height; prefix with a number, e.g.: 20<C-w>+
Ctrl+W _increase/decrease window height; prefix with a number, e.g.: 50<C-w>_
Ctrl+W >/<increase/decrease window width; prefix with a number, e.g.: 30<C-w><
Ctrl+W |increase/decrease window width; prefix with a number, e.g.: 30<C-w>|
Ctrl+W =equalise width and height of all windows
Ctrl+W sSplit current window in two horizontally
Ctrl+W vSplit current window in two vertically
Ctrl+W nCreate a new window and start editing an empty file in it.
Ctrl+W Ctrl+J, Ctrl+W downMove cursor to Nth window below current one.
Ctrl+W Ctrl+k, Ctrl+W upMove cursor to Nth window above current one.
Ctrl+W Ctrl+H, Ctrl+W lft, Ctrl+W backspMove cursor to Nth window left of current one.
Ctrl+W Ctrl+l, Ctrl+W rightMove cursor to Nth window right of current one.
Ctrl+W Shift-TMove buffer to a tab
Leader Assignments
, F5NerdTree file manager using directory of current file
, cdSet working directory to path of current file
, dDuplicate current line
, evOpen .vimrc in a new tab for editing
, fnEcho currently edited file's name to system clipboard
, ln
, tn
Toggle appearance of line numbers between absolute consecutive order and relative to current line
, nTurn off find highlighting — :nohl
, svsource .vimrc (reload settings)
, vexecute paste from system clipboard
, ypaste from system clipboard
, + (non-keypad)vertical resize +5 columns
, - (non-keypad)vertical resize -5 columns
Cursor Movement
hmove left
jmove down
kmove up
lmove right
Mmove to middle of screen
Lmove to bottom of screen
wjump forwards to the start of a word
Wjump forwards to the start of a word (words can contain punctuation)
ejump forwards to the end of a word
Ejump forwards to the end of a word (words can contain punctuation)
bjump backwards to the start of a word
Bjump backwards to the start of a word (words can contain punctuation)
0jump to the start of the line
^jump to the first non-blank character of the line
$jump to the end of the line
g_jump to the last non-blank character of the line
gggo to the first line of the document
Ggo to the last line of the document
5Ggo to line 5
fxjump to next occurrence of character x
txjump to before next occurrence of character x
}jump to next paragraph (or function/block, when editing code)
{jump to previous paragraph (or function/block, when editing code)
zzcenter cursor on screen
Ctrl+bmove back one full screen
Ctrl+fmove forward one full screen
Ctrl+dmove forward ½ a screen
Ctrl+umove back ½ a screen
Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
 Back to Table of Contents
Insert Mode - ways to commence editing
iinsert before the cursor
Iinsert at the beginning of the line
ainsert (append) after the cursor
Ainsert (append) at the end of the line
oappend (open) a new line below the current line
Oappend (open) a new line above the current line
eainsert (append) at the end of the word
Escexit insert mode
 Back to Table of Contents
NERDtree

Files

o:open in previous window
go:preview
t:open in new tab
T:open in new tab silently
i:open split
gi:preview split
s:open vsplit
gs:preview vsplit

Directories

o:open & close
O:recursively open
x:close parent
X:close all children recursively
e:explore selected directory

Bookmarks

o:open bookmark
t:open in new tab
T:open in new tab silently
D:delete bookmark

Filesystem

C:change tree root to selected dir
u:move tree root up a directory
U:move tree root up a directory but leave old root open
r:refresh cursor directory
R:refresh current root
m:show menu
cd:change the CWD to the selected dir
CDchange tree root to CWD
CommandExplain

Tree navigation

p:go to parent
P:go to root
K:go to first child
J:go to last child
Ctrl+k:go to previous sibling
Ctrl+j:go to next sibling

Tree filtring

I:hidden files (off)
f:file filters (on)
F:files (on)
B:bookmarks (off)

Other Commands

q:Close the NERDtree window
A:toggle zoom NERDtree window
?:toggle help
Editing
rreplace a single character
Jjoin line below to the current one
cc or Schange (replace) entire line
cwchange (replace) to the end of the word
c$change (replace) to the end of the line
sdelete character and substitute text
xptranspose two letters (delete and paste)
uundo
Ctrl+Rredo
. (period)repeat last command
 Back to Table of Contents
Working with Multiple Files
:e fileedit a file in a new buffer
:bnext or :bngo to the next buffer
:bprev or :bpgo to the previous buffer
:bddelete a buffer (close a file)
:lslist all open buffers
:sp fileopen a file in a new buffer and split window
:vsp fileopen a file in a new buffer and vertically split window
Ctrl + wssplit window
Ctrl + wwswitch windows
Ctrl + wqquit a window
Ctrl + wvsplit window vertically
Ctrl + whmove cursor to the left window (vertical split)
Ctrl + wlmove cursor to the right window (vertical split)
Ctrl + wjmove cursor to the window below (horizontal split)
Ctrl + wkmove cursor to the window above (horizontal split)
 Back to Table of Contents
Marking text (visual mode)
vstart visual mode, mark lines, then do a command (like y-yank)
Vstart linewise visual mode
omove to other end of marked area
Ctrl + vstart visual block mode
Omove to other corner of block
awmark a word
aba block with ()
aBa block with {}
ibinner block with ()
iBinner block with {}
Escexit visual mode
 Back to Table of Contents
Visual Commands
>shift text right
<shift text left
yyank (copy) marked text
ddelete marked text
~ (tilde)switch case
 Back to Table of Contents
Cut and Paste
yyyank (copy) a line
2yyyank (copy) 2 lines
ywyank (copy) the characters of the word from the cursor position to the start of the next word
y$yank (copy) to end of line
pput (paste) the clipboard after cursor
Pput (paste) before cursor
dddelete (cut) a line
2dddelete (cut) 2 lines
dwdelete (cut) the characters of the word from the cursor position to the start of the next word
Ddelete (cut) to the end of the line
d$delete (cut) to the end of the line
xdelete (cut) character
 Back to Table of Contents
Marks
:markslist if marks
maset current position for mark A
`ajump to position of mark A
y`ayank text to position of mark A
 Back to Table of Contents
Registers
:regshow registers content
"xyyank into register x
"xppaste contents of register x
Registers are stored in ~/.viminfo, and will be loaded again on next restart of vim.
Register 0 contains always the value of the last yank command.
 Back to Table of Contents
Search & Replace
/patternsearch for pattern
?patternsearch backward for pattern
\vpattern'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed)
nrepeat search in same direction
Nrepeat search in opposite direction
:%s/old/new/greplace all old with new throughout file
:%s/old/new/gcreplace all old with new throughout file with confirmations
:nohremove highlighting of search matches
 Back to Table of Contents
Search in multiple files
:vimgrep /pattern/ {file}search for pattern in multiple files
e.g: :vimgrep /foo/ **/*
:cnjump to the next match
:cpjump to the previous match
:copenopen a window containing the list of matches
 Back to Table of Contents
Tabs
:tabnew or
:tabnew file
open a file in a new tab
Ctrl+wTmove the current split window into its own tab
gt
:tabn
:tabnext
move to the next tab
gT
:tabprev
:tabp
move to the previous tab
#gtmove to the tab number #
:tabmove #move current tab to the #th position (indexed from 0)
:tabc or
:tabclose
close the current tab and all its windows
:tabo or
:tabonly
close all tabs except for the current one
:tabdorun the command on all tabs (e.g. :tabdo q - closes all opened tabs)
 Back to Table of Contents
Exiting
:wwrite [save] file but don't exit
:wqwrite [save]
:qquit [fails if file has changed]
:q!quit and throw away changes
 Back to Table of Contents

wmctrl

wmctrl help

help generated by wmctrl -h
Actions:

switchdescription
-mShow information about the window manager and about the environment.
-lList windows managed by the window manager.
-a <WIN>Activate the window by switching to its desktop and raising it.
-c <WIN>Close the window gracefully.
-R <WIN>Move the window to the current desktop and activate it.
-r <WIN> -t <DESK>Move the window to the specified desktop.
-r <WIN> -e <MVARG>Resize and move the window around the desktop. The format of the <MVARG> argument is described below.
-r <WIN> -b <STARG>Change the state of the window. Using this option it's possible for example to make the window maximized, minimized or fullscreen. The format of the <STARG> argument and list of possible states is given below.
( add | remove | toggle),prop1 [,prop2 ]

Add, remove, or toggle up to two window properties simultaneously
  1. modal
  2. sticky
  3. maximized_vert
  4. maximized_horz
  5. shaded
  6. skip_taskbar
  7. skip_pager
  8. hidden
  9. fullscreen
  10. above
  11. below

Following example will toggle window with title 'Notes - Zim' above other windows.
wmctrl -b toggle,shaded -r 'Notes - Zim'

-r <WIN> -N <STR>Set the name (long title) of the window.
-r <WIN> -I <STR>Set the icon name (short title) of the window.
-r <WIN> -T <STR>Set both the name and the icon name of the window.

Options:

switchdescription
-iInterpret <WIN> as a numerical window ID.
wmctrl -ir 0x06600031 -T "D78"
The hexadecimal string '0x06600031' is the intifier found using option -l above.
-GInclude geometry in the window list.
-FModifies the behavior of the window title matching algorithm. It will match only the full window title instead of a substring, when this option is used. Furthermore it makes the matching case sensitive.
-vBe verbose. Useful for debugging.