Skip to content

Instantly share code, notes, and snippets.

@geastwood
Last active December 23, 2016 18:56
Show Gist options
  • Save geastwood/11469912 to your computer and use it in GitHub Desktop.
Save geastwood/11469912 to your computer and use it in GitHub Desktop.
vim, cheatsheet

Vim CHEAT SHEET

Folding

Keystrokes Description
zc Close a fold
zo Open a fold
za Toggle a fold
zR Open all folds

Insert mode

Keystrokes Description
<C-h> backspace by character
<C-w> backspace by word
<C-u> backspace to beginning
<C-o> switch to insert normal mode
<C-r>= insert mode calculation

Copy & Paste

Keystrokes Description
"0p or "0P last yank is save to this register, use together with put

Search

Keystrokes Description
; forward repeat last search
, backward repeat last search

Spell check

Keystrokes Description
set spell turn on spell check
[s jump to next spell check error
]s jump to previous spell check error
z= bring up suggestions
{count}z= take automatically the first suggestion
zg add word to spell file
zw add word to spell file as a bad word

Visual mode

Keystrokes Description
gv reselect
<C-g> toggle between visual and select mode
o toggle the open end of the visual selection

Navigation

Keystrokes Description
zz bring the cursor to vertical middle of screen
zt bring the cursor to vertical top of screen
zb bring the cursor to vertical bottom of screen
<C-u> scroll up Half screen
<C-b> scroll up Full screen
<C-d> scroll down Half screen
<C-f> scroll down Full screen

custom short-hand

Keystrokes Description
,w save the current file
<C-j> move current line down (require "tpope/vim-unimpaired")
<C-k> move current line up (require "tpope/vim-unimpaired")
,l expend current window with 10 columns
,s toggle spell checking

Indentation

Keystrokes Description
>> indent current line/selection one level right
<< indent current line/selection one level left
>2> indent current line/selection 2 level right
<C-t> Insert Mode indent current line one level right
<C-d> Insert Mode indent current line one level left

[NERDTree] (https://github.com/scrooloose/nerdtree "NerdTree on Github")

Keystrokes Description
m open menu
o open a file at side

Setting current folder

Keystrokes Description
:cd set current directory to user directory
:cd path\to\folder set current directory to path\to\folder
:cd %:h set cuurent directory to the folder containing current file
'%' -> current file name including path, ':' modifier, 'h' is head

Others

Keystrokes Description
fg angehalten
J Join line

under Mac copy & paste

vim wiki

READ ME FIRST

  • leader key is remapped to , by let mapleader = ","
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment