임베디드 | 라즈베리파이 | ARM | 리눅스 | Qt | 딥러닝

vi 단축키 cheat sheet 모음입니다.


Quitting

:xExit, saving changes
:qExit as long as there have been no changes
ZZExit and save changes if any have been made
:q!Exit and ignore any changes


Inserting Text

iInsert before cursor
IInsert before line
aAppend after cursor
AAppend after line
oOpen a new line after current line
OOpen a new line before current line
rReplace one character
RReplace many characters



Motion

hMove left
jMove down
kMove up
lMove right
wMove to next word
WMove to next blank delimited word
bMove to the beginning of the word
BMove to the beginning of blank delimted word
eMove to the end of the word
EMove to the end of Blank delimited word
(Move a sentence back
)Move a sentence forward
{Move a paragraph back
}Move a paragraph forward
0Move to the begining of the line
$Move to the end of the line
1GMove to the first line of the file
GMove to the last line of the file
nGMove to nth line of the file
:nMove to nth line of the file
fcMove forward to c
FcMove back to c
HMove to top of screen
MMove to middle of screen
LMove to botton of screen
%Move to associated ( ), { }, [ ]
:0Move to the beginning of the file
:$Move to the end of the file
[ctrl] + dgo down half a screen
[ctrl] + ugo up half a screen
[ctrl] + fgo forward a screen
[ctrl] + bgo back a screen


Modes

Vi has two modes insertion mode and command mode. The editor begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode (where you can quit, for example by typing :q!). Most commands execute as soon as you type them except for "­col­on" commands which execute when you press the ruturn key.



Deleting Text

xDelete character to the right of cursor
XDelete character to the left of cursor
DDelete to the end of the line
ddDelete current line
:dDelete current line



Yanking Text

yyYank the current line
:yYank the current line

Changing text

CChange to the end of the line
ccChange the whole line
guulowercase line
gUUuppercase line
~Toggle upp and lower case

Putting text

pPut after the position or after the line
PPut before the poition or before the line

Markers

mcSet marker c on this line
`cGo to beginning of marker c line.
'cGo to first non-blank character of marker c line.


Search for strings

/stringSearch forward for string
?stringSearch back for string
nSearch for next instance of string
NSearch for previous instance of string

Replace

:s/pat­ter­n/s­tri­ng/­flagsReplace pattern with string according to flags.
gFlag - Replace all occurences of pattern
cFlag - Confirm replaces.
&Repeat last :s command

Ranges

:n,mRange - Lines n-m
:.Range - Current line
:$Range - Last line
:'cRange - Marker c
:%Range - All lines in file
:g/pat­tern/Range - All lines that contain pattern

Files

:w fileWrite to file
:r fileRead file in after line
:nGo to next file
:pGo to previous file
:e fileEdit file
!!pro­gramReplace line with output fromprogram

Other

JJoin lines
.Repeat last text-c­hanging command
uUndo last change
UUndo all changes to line




참고 : http://www.cheatography.com/ericg/cheat-sheets/vi-editor/