home » linux » git | sed | vi

VI - Kurzreferenz

:q quit
:q! forced quit w/o write
:w write
:wq write quit
:x write quit
h j k l cursor movement
10h move 10 char to left
25j move 25 lines down
0 (null) go to beginning of line
$ go to end of line
gg go to beginning of file
G go to the end of file
CTRL+f scroll forward one screen
CTRL+b scroll backward one screen
a insert text after cursor
A append at end of line
i insert text before cursor
I insert text before line
o open new line below
O open new line above
x delete char after
X delete char before
dw delete word after
db delete word before
d^ delete from line beginning
d$ delete to line end
dd delete current line
xxdd delete xx lines
yw copy/yank word after
yb copy/yank word before
y^ copy/yank line before
y$ copy/yank line after
yy copy/yank current line
p paste after
P paste before
/string search for "string"
/ search again for last "string"
n next search
?string search for "string" backwards
? search again for "string" backwards
J join two lines
u undo
U undo/restore current line
. repeat the last command

regex

:s/old_string/new_string substitude/replace first "old_string" in line
:s/old_string/new_string/g substitude/replace all "old_strings" in line
:1,$s/..... substitude/replace in all lines of the file
:/string/d remove all lines containing "string"
:/string/!d remove all lines not containing "string"

Sonstiges (~/.vimrc)

:syntax on turn syntax highlighting on
:set bg=dark change font colors for dark backgrounds
:highlight Comment ctermfg=darkgrey change color for comments

zurück