Sie sind auf Seite 1von 7

11/20/2016

VimCommandsCheatSheet

VimCommandsCheatSheet
HowtoExit
:q[uit]
:q[uit]!
:cq[uit]
:wq
:wq!
:wq{file}
:wq!{file}
:[range]wq[!]
ZZ
ZQ

QuitVim.Thisfailswhenchangeshavebeenmade.
Quitwithoutwriting.
Quitalways,withoutwriting.
Writethecurrentfileandexit.
Writethecurrentfileandexitalways.
Writeto{file}.Exitifnoteditingthelast
Writeto{file}andexitalways.
[file]Sameasabove,butonlywritethelinesin[range].
Writecurrentfile,ifmodified,andexit.
Quitcurrentfileandexit(sameas":q!").

EditingaFile
:e[dit]
:e[dit]!
:e[dit]
{file}
:e[dit]!
{file}
gf

Editthecurrentfile.Thisisusefultoreeditthecurrentfile,whenithasbeenchangedoutsideof
Vim.
Editthecurrentfilealways.Discardanychangestothecurrentbuffer.Thisisusefulifyouwantto
startalloveragain.
Edit{file}.
Edit{file}always.Discardanychangestothecurrentbuffer.
Editthefilewhosenameisunderorafterthecursor.Mnemonic:"gotofile".

InsertingText
a
A
i

Appendtextafterthecursor[count]times.
Appendtextattheendoftheline[count]times.
Inserttextbeforethecursor[count]times.

I Inserttextbeforethefirstnonblankintheline[count]times.
gI Inserttextincolumn1[count]times.
o
O

Beginanewlinebelowthecursorandinserttext,repeat[count]times.
Beginanewlineabovethecursorandinserttext,repeat[count]times.

https://www.fprintf.net/vimCheatSheet.html

1/7

11/20/2016

VimCommandsCheatSheet

Insertingafile
:r[ead][name]
:r[ead]!{cmd}

Insertthefile[name]belowthecursor.
Execute{cmd}andinsertitsstandardoutputbelowthecursor.

DeletingText
<Del>or
x
X

Delete[count]charactersunderandafterthecursor
Delete[count]charactersbeforethecursor

d{motion}
dd

Deletetextthat{motion}movesover
Delete[count]lines

D
{Visual}xor
{Visual}d
{Visual}CTRLHor
{Visual}

Deletethecharactersunderthecursoruntiltheendoftheline
Deletethehighlightedtext(for{Visual}seeSelectingText).
WheninSelectmode:Deletethehighlightedtext

{Visual}Xor
{Visual}D

Deletethehighlightedlines

:[range]d[elete]

Delete[range]lines(default:currentline)

:[range]d[elete]{count}

Delete{count}lines,startingwith[range]

Changing(orReplacing)Text
r{char}

replacethecharacterunderthecursorwith{char}.

EnterInsertmode,replacingcharactersratherthaninserting

Switchcaseofthecharacterunderthecursorandmovethecursortotheright.Ifa[count]isgiven,
dothatmanycharacters.

~
switchcaseof{motion}text.
{motion}
{Visual}~ Switchcaseofhighlightedtext

Substituting
:[range]s[ubstitute]/{pattern}/{string}/[c]
Foreachlinein[range]replaceamatchof{pattern}with{string}.
[e][g][p][r][i][I][count]
:[range]s[ubstitute][c][e][g][r][i][I]
Repeatlast:substitutewithsamesearchpatternandsubstitute
[count]:[range]&[c][e][g][r][i][I][count] string,butwithoutthesameflags.Youmayaddextraflags

https://www.fprintf.net/vimCheatSheet.html

2/7

11/20/2016

VimCommandsCheatSheet

Theargumentsthatyoucanuseforthesubstitutecommands:
[c]Confirmeachsubstitution.Vimpositionsthecursoronthematching
string.Youcantype:
'y'tosubstitutethismatch
'n'toskipthismatch
toskipthismatch
'a'tosubstitutethisandallremainingmatches{notinVi}
'q'toquitsubstituting{notinVi}
CTRLEtoscrollthescreenup{notinVi}
CTRLYtoscrollthescreendown{notinVi}.
[e]Whenthesearchpatternfails,donotissueanerrormessageand,in
particular,continueinmapsasifnoerroroccurred.
[g]Replacealloccurrencesintheline.Withoutthisargument,
replacementoccursonlyforthefirstoccurrenceineachline.
[i]Ignorecaseforthepattern.
[I]Don'tignorecaseforthepattern.
[p]Printthelinecontainingthelastsubstitute.

CopyingandMovingText
"{azAZ0
9.%#:"}

Useregister{azAZ09.%#:"}fornextdelete,yankorput(useuppercasecharacterto
appendwithdeleteandyank)({.%#:}onlyworkwithput).

:reg[isters]
:reg[isters]
{arg}

Displaythecontentsofallnumberedandnamedregisters.
Displaythecontentsofthenumberedandnamedregistersthatarementionedin{arg}.

:di[splay][arg] Sameas:registers.
["x]y{motion}
["x]yy

Yank{motion}text[intoregisterx].
Yank[count]lines[intoregisterx]

["x]Y

yank[count]lines[intoregisterx](synonymforyy).

{Visual}["x]y
{Visual}["x]Y

Yankthehighlightedtext[intoregisterx](for{Visual}seeSelectingText).
Yankthehighlightedlines[intoregisterx]

:[range]y[ank]
[x]

Yank[range]lines[intoregisterx].

:[range]y[ank]
[x]{count}

Yank{count}lines,startingwithlastlinenumberin[range](default:currentline),[into
registerx].

["x]p

Putthetext[fromregisterx]afterthecursor[count]times.

["x]P

Putthetext[fromregisterx]beforethecursor[count]times.

["x]gp
["x]gP

Justlike"p",butleavethecursorjustafterthenewtext.
Justlike"P",butleavethecursorjustafterthenewtext.

:[line]pu[t][x] Putthetext[fromregisterx]after[line](defaultcurrentline).
:[line]pu[t]![x] Putthetext[fromregisterx]before[line](defaultcurrentline).

Undo/Redo/Repeat
u

Undo[count]changes.

:u[ndo]

Undoonechange.

https://www.fprintf.net/vimCheatSheet.html

3/7

11/20/2016

VimCommandsCheatSheet

CTRLR
:red[o]

Redo[count]changeswhichwereundone.
Redoonechangewhichwasundone.

Undoalllatestchangesononeline.{Vi:whilenotmovedoffofit}

Repeatlastchange,withcountreplacedwith[count].

MovingAround
Basicmotioncommands:
k
hl
j

hor

[count]characterstotheleft(exclusive).

lor
or

[count]characterstotheright(exclusive).

kor
or
CTRLP

[count]linesupward

jor
or
CTRLJor
or
CTRLN

[count]linesdownward(linewise).

Tothefirstcharacteroftheline(exclusive).

<Home>
^

Tothefirstcharacteroftheline(exclusive).
Tothefirstnonblankcharacteroftheline

$or
<End>

Totheendofthelineand[count1]linesdownward

g0or
g<Home>

Whenlineswrap('wrapon):Tothefirstcharacterofthescreenline(exclusive).Differsfrom
"0"whenalineiswiderthanthescreen.Whenlinesdon'twrap('wrap'off):Totheleftmost
characterofthecurrentlinethatisonthescreen.Differsfrom"0"whenthefirstcharacterof
thelineisnotonthescreen.

g^

Whenlineswrap('wrap'on):Tothefirstnonblankcharacterofthescreenline(exclusive).
Differsfrom"^"whenalineiswiderthanthescreen.Whenlinesdon'twrap('wrap'off):Tothe
leftmostnonblankcharacterofthecurrentlinethatisonthescreen.Differsfrom"^"whenthe
firstnonblankcharacterofthelineisnotonthescreen.

g$or
g<End&gr

Whenlineswrap('wrap'on):Tothelastcharacterofthescreenlineand[count1]screenlines
downward(inclusive).Differsfrom"$"whenalineiswiderthanthescreen.Whenlinesdon't
wrap('wrap'off):Totherightmostcharacterofthecurrentlinethatisvisibleonthescreen.
Differsfrom"$"whenthelastcharacterofthelineisnotonthescreenorwhenacountisused.

f{char}
F{char}

To[count]'thoccurrenceof{char}totheright.Thecursorisplacedon{char}(inclusive).
Tothe[count]'thoccurrenceof{char}totheleft.Thecursorisplacedon{char}(inclusive).

t{char}

Tillbefore[count]'thoccurrenceof{char}totheright.Thecursorisplacedonthecharacter
leftof{char}(inclusive).

T{char}

Tillafter[count]'thoccurrenceof{char}totheleft.Thecursorisplacedonthecharacterright
of{char}(inclusive).

https://www.fprintf.net/vimCheatSheet.html

4/7

11/20/2016

VimCommandsCheatSheet

Repeatlatestf,t,ForT[count]times.

Repeatlatestf,t,ForTinoppositedirection[count]times.

<minus>
+or
CTRLMor
<CR>

[count]linesupward,onthefirstnonblankcharacter(linewise).
[count]linesdownward,onthefirstnonblankcharacter(linewise).

_
[count]1linesdownward,onthefirstnonblankcharacter(linewise).
<underscore>
<CEnd>or
G

Gotoline[count],defaultlastline,onthefirstnonblankcharacter.

<CHome>
or
gg

Gotoline[count],defaultfirstline,onthefirstnonblankcharacter.

<SRight>or
[count]wordsforward
w
<CRight>or
[count]WORDSforward
W
e

Forwardtotheendofword[count]

E
<SLeft>or
b

ForwardtotheendofWORD[count]
[count]wordsbackward

<CLeft>or
B

[count]WORDSbackward

ge

Backwardtotheendofword[count]

gE

BackwardtotheendofWORD[count]

ThesecommandsmoveoverwordsorWORDS.
Awordconsistsofasequenceofletters,digitsandunderscores,orasequenceofothernonblankcharacters,
separatedwithwhitespace(spaces,tabs,).Thiscanbechangedwiththe'iskeyword'option.
AWORDconsistsofasequenceofnonblankcharacters,separatedwithwhitespace.Anemptylineisalso
consideredtobeawordandaWORD.
( [count]sentencesbackward
) [count]sentencesforward
{ [count]paragraphsbackward
} [count]paragraphsforward
]]

[count]sectionsforwardortothenext'{'inthefirstcolumn.Whenusedafteranoperator,thenthe'}'inthe
firstcolumn.

][ [count]sectionsforwardortothenext'}'inthefirstcolumn
[[ [count]sectionsbackwardortotheprevious'{'inthefirstcolumn
[] [count]sectionsbackwardortotheprevious'}'inthefirstcolumn
Screenmovementcommands
z.

Centerthescreenonthecursor

https://www.fprintf.net/vimCheatSheet.html

5/7

11/20/2016

VimCommandsCheatSheet

zt

Scrollthescreensothecursorisatthetop

zb

Scrollthescreensothecursorisatthebottom

Marks
m{azAZ}
m'or
m`

Setmark{azAZ}atcursorposition(doesnotmovethecursor,thisisnotamotion
command).
Setthepreviouscontextmark.Thiscanbejumpedtowiththe"''"or"``"command(doesnot
movethecursor,thisisnotamotioncommand).

:[range]ma[rk]
Setmark{azAZ}atlastlinenumberin[range],column0.Defaultiscursorline.
{azAZ}
:[range]k{azA
Sameas:mark,butthespacebeforethemarknamecanbeomitted.
Z}
'{az}

Tothefirstnonblankcharacteronthelinewithmark{az}(linewise).

'{AZ09}
`{az}

Tothefirstnonblankcharacteronthelinewithmark{AZ09}inthecorrectfile
Tothemark{az}

`{AZ09}

Tothemark{AZ09}inthecorrectfile

:marks

Listallthecurrentmarks(notamotioncommand).

:marks{arg}

Listthemarksthatarementionedin{arg}(notamotioncommand).Forexample:

Searching
/{pattern}[/]
/{pattern}/{offset}

Searchforwardforthe[count]'thoccurrenceof{pattern}
Searchforwardforthe[count]'thoccurrenceof{pattern}andgo{offset}linesupor
down.

/<CR>

Searchforwardforthe[count]'thlatestusedpattern

//{offset}<CR>

Searchforwardforthe[count]'thlatestusedpatternwithnew.If{offset}isemptyno
offsetisused.

?{pattern}[?]<CR> Searchbackwardforthe[count]'thpreviousoccurrenceof{pattern}
?{pattern}?{offset} Searchbackwardforthe[count]'thpreviousoccurrenceof{pattern}andgo{offset}
<CR>
linesupordown
?<CR>

Searchbackwardforthe[count]'thlatestusedpattern

??{offset}<CR>

Searchbackwardforthe[count]'thlatestusedpatternwithnew{offset}.If{offset}is
emptynooffsetisused.

Repeatthelatest"/"or"?"[count]times.

Repeatthelatest"/"or"?"[count]timesinoppositedirection.

SelectingText(VisualMode)
https://www.fprintf.net/vimCheatSheet.html

6/7

11/20/2016

VimCommandsCheatSheet

Toselecttext,entervisualmodewithoneofthecommandsbelow,andusemotioncommandstohighlightthe
textyouareinterestedin.Then,usesomecommandonthetext.
Theoperatorsthatcanbeusedare:
~switchcase
ddelete
cchange
yyank
>shiftright
<shiftleft
!filterthroughexternalcommand
=filterthrough'equalprg'optioncommand
gqformatlinesto'textwidth'length

startVisualmodepercharacter.

startVisualmodelinewise.

<Esc>

exitVisualmodewithoutmakinganychanges

HowtoSuspend
CTRLZ

SuspendVim,like":stop".WorksinNormalandinVisualmode.InInsertandCommandline
mode,theCTRLZisinsertedasanormalcharacter.

:sus[pend] SuspendVim.Ifthe'!'isnotgivenand'autowrite'isset,everybufferwithchangesandafilename
[!]or
iswrittenout.Ifthe'!'isgivenor'autowrite'isnotset,changedbuffersarenotwritten,don'tforget
:st[op][!] tobringVimbacktotheforegroundlater!

DanielGryniewicz/dang@fprintf.net

https://www.fprintf.net/vimCheatSheet.html

7/7

Das könnte Ihnen auch gefallen