====== VI / VIM ======
===== Short Version =====
==== Minimal functionality ====
|''h j k l ''| | Arrow keys |
|''Esc''|''C-C''| Exit insert mode|
|'':w''| | save |
|'':q''|'':q!'' | quit, confirm quit without saving |
|''i''|''a''| Insert mode at or after cursor |
|''d''|''dd''| Delete, delete line |
==== Extended ====
|''u''|| undo |
|''/pattern''|''?pattern''| search forwards, backwards|
|''n''|''N''| Continue search
==== Copy / paste ====
|''v''| | visual mode |
|''y''| | yank = copy |
|''p''| | paste after cursor |
|''''| | |
|''''| | |
===== Minimal .vimrc =====
"+y #copy a selection to the system clipboard
"+p #paste from system clipboard
set nocompatible " Modernes Verhalten statt original Vi
filetype plugin indent on
set autoindent
set ts=4
filetype on
syntax on
" Darstellung & Nummerierung
set number " Zeilennummern anzeigen
set relativenumber " Zeilennummern relativ zum Cursor anzeigen
set showcmd " Unvollständige Befehle in der Statusleiste anzeigen
set wildmenu " Bessere Tab-Vervollständigung für Befehle
" Suchen
set hlsearch " Suchergebnisse hervorheben
set incsearch " Live-Suche während der Eingabe aktivieren
set ignorecase " Groß-/Kleinschreibung bei der Suche ignorieren
set smartcase " Großschreibung erzwingen, wenn Großbuchstaben enthalten sind
" Tabs und Einrückung
set tabstop=4 " Tabulator entspricht 4 Leerzeichen
set shiftwidth=4 " Einrückungstiefe ebenfalls 4 Leerzeichen
set expandtab " Tabs in Leerzeichen umwandeln
set autoindent " Automatische Einrückung für neue Zeilen
" Verhalten
set backspace=indent,eol,start " Korrektes Löschen mit der Backspace-Taste
set hidden " Puffer ohne Speichern im Hintergrund behalten
===== Long Version =====
==== Edit ====
i - insert before the cursor
I - insert at the beginning of the line
a - insert (append) after the cursor
A - insert (append) at the end of the line
o - append (open) a new line below the current line
O - append (open) a new line above the current line
==== Clipboard ====
x Delete character
dd Delete line (Cut)
yy Yank line (Copy)
p Paste
P Paste before
"*p / "+p Paste from system clipboard
"*y / "+y Paste to system clipboar
==== Exit ====
:q Close file
:qa Close all files
:w Save
:wq / :x Save and close file
ZZ Save and quit
:q! / ZQ Quit without checking changes
==== Visual mode ====
v Enter visual mode
V Enter visual line mode
Enter visual block mode
In visual mode
d / x Delete selection
s Replace selection
y Yank selection (Copy)
==== Navigating ====
=== Directions ===
h j k l Arrow keys
/ Half-page up/down
/ Page up/down
=== Words ===
b / w Previous/next word
ge / e Previous/next end of word
Line
0 (zero) Start of line
^ Start of line (after whitespace)
$ End of line
=== Character ===
fc Go forward to character c
Fc Go backward to character c
Document
gg First line
G Last line
:{number} Go to line {number}
{number}G Go to line {number}
{number}j Go down {number} lines
{number}k Go up {number} lines
=== Window ===
zz Center this line
zt Top this line
zb Bottom this line
H Move to top of screen
M Move to middle of screen
L Move to bottom of screen
=== Search ===
n Next matching search pattern
N Previous match
* Next whole word under cursor
# Previous whole word under cursor
==== Operators ====
=== Usage ===
Operators let you operate in a range of text (defined by motion). These are performed in normal mode.
d w
Operator Motion
Operators list
d Delete
y Yank (copy)
c Change (delete then insert)
> Indent right
< Indent left
= Autoindent
==== Spell checking ====
:set spell spelllang=en_us Turn on US English spell checking
]s Move to next misspelled word after the cursor
[s Move to previous misspelled word before the cursor
z= Suggest spellings for the word under/after the cursor
zg Add word to spell list
zw Mark word as bad/misspelling
zu / C-X (Insert Mode) Suggest words for bad word under cursor from spellfile
==== File Tabs ====
:e filename - Edit a file
:tabe - Make a new tab
gt - Go to the next tab
gT - Go to the previous tab
:vsp - Vertically split windows
ctrl+ws - Split windows horizontally
ctrl+wv - Split windows vertically
ctrl+ww - Switch between windows
ctrl+wq - Quit a window