index
Latest update: November 11, 2020
Help
- :h[elp] Top-level help
- :h[elp] {pattern} Help matching a pattern
- :helpc[lose] Close one help window
Options
- :so[urce] $MYVIMRC Reload config file
- :se[t] Show all options that differ from default
- :se[t] {option}? Show value of {option}
- :se[t] {option}& Reset option to default value
- :se[t] {option} Set toggle type option to true
- :se[t] no{option} Set toggle type option to false
- :se[t] {option}={value} Set string or number type {option} to {value}
Tags
- :ta[g] {tag} Jump to tag {tag}
- Ctrl + ] Jump to tag under cursor
- Ctrl + T Jump to [count] older tag
- :[count]ta[g] Jump to [count] newer tag
- :tags Show tag stack
Files
- :w Write file
- :wqa Write all files
- :q Quit unless pending changes
- :q! Quit and ignore pending changes
Buffers
- :ls List all buffers
- :b {number|name} Go to buffer
number, or buffer matching unique name (supports tab completion)
- :bn Go to next buffer in list
- :bp Go to previous buffer in list
- :bd [{number|name}] Close current or
matching buffer
- :bufdo {cmd} Execute {cmd} in all buffers
Windows
- vim -o {files} Open all {files} in their own horizontally split window
- vim -O {files} Open all {files} in their own vertically split window
- CTRL-W s Split current window in two horizontally
- CTRL-W v Split current window in two vertically
- CTRL-W c Close current window
- CTRL-W o Close all windows except the current one
- CTRL-W n Create a new horizontally split window with an empty file
- :new {file} Open {file} in a new horizontally split window
Tabs
- :h tabpage Help on tabs
- vim -p {files} Open all {files} in their own tab
- :tabe Open a new tab
- :tabe {file} Open {file} in a new tab
- gt Go to next tab
- gT Go to previous tab
- {num}gt Go to tab index {num}
- :tabc Close the current tab
- :tabo Close all tabs except the current one
- :tabs List tabs
Sessions
- :mks {file} Save current state of vim to {file} (or ./Session.vim if omitted)
- vim -S {file} Restore saved session from {file} (or ./Session.vim if omitted)
Basic navigation
- h Left
- j Down
- k Up
- l Right
Words
- w Start of next word
- W Start of next word (with punctuation)
- b Start of last word
- B Start of last word (with punctuation)
- e End of next word
- E End of next word (with punctuation)
Scrolling
- Ctrl + e Scroll one line down
- Ctrl + y Scroll one line up
- Ctrl + d Scroll half screen down
- Ctrl + u Scroll half screen up
- Ctrl + f Scroll full screen down
- Ctrl + b Scroll full screen up
- zzScroll so that current line is centered
Navigate lines
- 0 Line start
- $ Line end
- ^ or _ First non-blank character of line
- g_ Last non-blank character of line
- f{char}Next occurence of {char}
- F{char}Prev occurence of {char}
- t{char}Next occurence of {char} (place cursor before)
- T{char}Prev occurence of {char} (place cursor before)
- ;Repeat last fFtT
- ,Repeat last fFtT in reverse
Navigate screen
- H Screen top
- M Screen middle
- L Screen bottom
Navigate structurally
- % Jump to matching
()
, {}
, or []
pair
- } Next paragraph/block
- { Previous paragraph/block
Navigate file
- gg Start of file
- G End of file
- :n or nG Line n of file
Copy/Paste
- y Copy selection
- yy or Y Copy current line
- y$ Copy to end of line without newline
- d Cut selection
- dd Cut line
- D Cut to end of line
- p Paste clipboard after cursor
- P Paste clipboard before cursor
- :pu Paste to new line above
- :pu! Paste to new line below
Editing lines
- J Join next line to current, with space
- gJ Join next line to current, without space
- cc Replace line
- C Replace to end of line
- I Insert text at beginning of line
- A Insert text at end of line
- d{linenum}G Delete from the current line to {linenum}
Editing characters
- ~ Toggle case
- x Cut character
- xp Transpose
Search/Replace
- /pattern Search for pattern
- ?pattern Search for pattern backwards
- n Next match
- N Previous match
- ggn First match
- GN Last match
- * Search for word under cursor
- g* Search for word under cursor (without word boundaries)
- # Reverse version of *
- g$ Reverse version of g*
Selecting (visual mode)
- v Select characters
- V Select lines
- Ctrl + v Select columns
- gv Select previous range
Macros
- q{letter} Start recording to register {letter}
- q Stop recording
- {number}@{letter} Play macro {letter}, {number} times
- {number}@@ Play previously played macro
- :norm[al] @{letter} Play macro {letter} on all lines in selection
- :reg[isters] 1a Show contents of register 1 and a
VSCodeVim
- gd Jump to definition
- gh Show mouse-hover tooltip at cursor
Registers
- :reg[isters] Show all registers
- " Unnamed (most recent yank, delete etc.)
- + Clipboard X selection
- * Primary X selection
- a-zA-Z Explicitly referenced registers
- 0 Most recent yank
- 1-9 Most recent deletes and changes (lower is more recent)
- % Current file name
- _ Black hole
Misc
git show branch:file
Show file in other branch without switching
git commit --amend --date="$(date -R)"
Amend commit with new date
git ls-files --cached --ignored --exclude-standard
List files that should be ignored, but are checked in
git fetch origin pull/PRNUM/head:BRANCHNAME && git checkout BRANCHNAME
Fetch a pull request locally (even if forked)
git show -- . ':!package-lock.json' ':!**/package-lock.json'
Show commit but exclude some file patterns
git grep "TERM" $(git rev-list --all)
Search for string across all commits
git checkout COMMIT -- .
Copy state of a commit to the working directory
Misc
npm pack --dry-run 2<&1 | grep -Eo '[0-9]+(\.[0-9]+)?[kMG]?B+\s+.+' | sort -k2
Dry-run pack, sorted by filename
Misc
rg -tts PATTERN
Only search TypeScript files
rg -Tts PATTERN
Don't search TypeScript files
rg --no-ignore PATTERN
Don't respect .gitignore
etc.
rg -g '**/*test*' PATTERN
Only search files with test
in their name
rg --files -g '**/*test*'
List all files with test
in their names
Misc
sudo update-alternatives --get-selections
List defaults
sudo update-alternatives --config x-terminal-emulator
Update default terminal
Focus window
- Super + h Focus left
- Super + j Focus down
- Super + k Focus up
- Super + l Focus right
Move window
- Super + Shift + h Move left
- Super + Shift + j Move down
- Super + Shift + k Move up
- Super + Shift + l Move right
Resize window
- Super + Right Click + Drag Resize
- Super + Alt + k Move top edge up
- Super + Alt + j Move top edge down
- Super + Alt + l Move right edge right
- Super + Alt + h Move right edge left
- Super + Alt + Shift + k Move bottom edge up
- Super + Alt + Shift + j Move bottom edge down
- Super + Alt + Shift + h Move left edge right
- Super + Alt + Shift + l Move left edge left
Workspaces
- Super + 0-9 Switch to workspace
- Super + Shift + 0-9 Move window to workspace
- Super + r Rename workspace
Layout
- Super + e Tiled layout (default)
- Super + s Stacked layout
- Super + w Tabbed layout
Fullscreen
- Super + f Toggle fullscreen
Floating
- Super + Shift + Space Toggle window floating
- Super + Space Toggle between floating/tiled layers
- Super + p Toggle sticky
- Super + Drag Move floating window
Container splitting
- Super + v Split vertically
- Super + b Split horizontally
Container focus
- Super + a Focus parent container
- Super + Shift + a Focus child container
Kill window
- Super + Shift + q Kill window
Launching apps
- Super + d Open dmenu launcher
- Super + Enter Open a terminal
- Super + c Open a browser
Scratchpad
- Super + Shift + Backslash Move to scratchpad
- Super + Backslash Cycle through scratchpad windows
Special scratchpad windows
- Super + ? Toggle cheat sheet
- Super + m Toggle music player
- Super + y Toggle YouTube player
- Super + ` Toggle terminal
Screenshot
- Super + Shift + s Draw region and screenshot to clipboard
Reload/Restart/Exit i3
- Super + Shift + c Reload config file
- Super + Shift + r Restart i3
- Super + Shift + e Exit i3
- Ctrl + Alt + c Copy to clipboard
- Ctrl + Alt + v Paste from clipboard
- Alt + Shift + Drag Rectangular selection
- Alt + s Search scrollback
- Up/Down arrow Next/Previous search result
Dev tools
- Ctrl + Shift + j Toggle devtools
- Ctrl + Shift + f Search all resources
- Ctrl + Shift + c Inspect element
- Ctrl + ` Focus console
Debugger
- Ctrl + \ Pause/resume
- Ctrl + ' Step over
- Ctrl + ; Step into
- Ctrl + Shift + ; Step out
Tabs
- Ctrl + Tab or Ctrl + Page Up Next tab
- Ctrl + Shift + Tab or Ctrl + Page Down Previous tab
- Ctrl + Shift + t Re-open last closed tab
URL and Search
- Ctrl + l Jump to address bar (URL)
- Ctrl + e Jump to address bar (search)
- Alt + Enter Open URL/search in new tab
- Shift + Delete Delete highlighted suggestion
Misc
- Alt + f Open Chrome menu
- Ctrl + h History
- Ctrl + j Downloads
- Ctrl + u View source
- Ctrl + 0 Reset zoom
Bookmarks
- Ctrl + d Bookmark page
- Ctrl + Shift + o Bookmarks browser
- Ctrl + Shift + b Toggle bookmarks bar
Find on page
- Ctrl + f Find on page page
- Ctrl + g Next match
- Ctrl + Shift + g Previous match
Links
- Ctrl + Left Click Open link in new tab
- Ctrl + Shift + Left Click Open link in new tab and open it
Back/Forward
- Alt + Left Arrow Back
- Alt + Right Arrow Forward