반응형
다시 보기 위해 적는 vscode Vim extension 키 사용법.
Normal Mode
Motion
h
커서를 왼쪽으로j
커서 아래로k
커서 위로l
커서 오른쪽으로i
Insert mode<ESC>
<Ctrl-C>
<Ctrl-[>
Go to Normal mode
단어별 이동
word는 괄호 문자 포함 X, WORD는 포함 O
w
move to the beginning of next wordb
move to the beginning of the previous worde
move to the end of the next wordge
move to the end of the previous word
W
move to the beginning of next WORDB
move to the beginning of the previous WORDE
move to the end of the next WORDgE
move to the end of the previous WORD
알파벳 문자 하나 검색(하나의 코드 줄에서)
해당 문자로 커서 이동
f{character}
Find next occurrence of characterF{character}
Find previous occurrence of character
찾는 문자 하나 앞의 문자로 커서 이동
t{character}
Find next occurrence of character and place cursor just before itT{character}
Find previous occurrence of character and place cursor just before it
다음 or 이전의 일치하는 문자로 이동
;
Go to next occurrence of {character},
Go to previous occurrence of {character}
수평 방향으로 커서 이동(단일 줄에서)
줄의 앞과 끝
0
Moves to the first character of a line^
Moves to the first non-blank character of a line$
Moves to the end of a lineg_
Moves to the non-blank character at the end of a line
수직 방향으로 빠르게 이동하기
문단 단위 or 페이지 단위
}
Jumps entire paragraphs downwards{
similarly but upwardsCTRL-D
lets you move down half a page by scrolling the pageCTRL-U
lets you move up half a page also by scrolling
검색 기능(하나의 파일 내에서 검색)
/{pattern}
Search for {pattern}. {pattern} is a regex.?{pattern}
Search for {pattern} backwards.
/
Repeat last search forwards?
Repeat last search backwards
n
Go to next matchN
Go to previous match
count를 활용해서 더욱 빠르게.
{count}{motion}
Repeat {motion} {count} times
2w
Jump to second word4f"
Jump to fourth occurrence of the " character3/cucumber
Jump to third match of "cucumber"
Move Semantically
gd
Go to definition (of the word under the cursor)gf
Go to file (for file under the cursor)
이외의 core motion들
gg
Go to the top of the file{line}gg
Go to {line}G
Go to the end of the file%
jump to matching ({[]})
Operator
Edit with vim operators
{operator}{count}{motion}
Apply operator on bit of text covered by motion
d
deletec
changey
yank (copy)p
p (paste)g~
switch case>
shift right<
shift left=
format
LineWise
dd
delete a linecc
change a lineyy
yank (copy) a lineg~~
switch case of a line>>
shift line right<<
shift lineleft==
format line
Capital Case operator더 Strong한 ver
D
delete from cursor to the end of the lineC
change from cursor to the end of the lineY
yank (copy) a line. Like yyP
put (paste) before the cursor
text object와 operator
{operator}a{text-object}
Apply operator to all text-object including trailing whitespace{operator}i{text-object}
Apply operator inside text-object
diw
delete inner worddaw
delete a worddis
delete inner sentencedas
delete a sentencedip
delete inner paragraphdap
delete a paragraphdi(dib
delete inside parenthesesda(
dab
delete text inside parentheses (including parentheses)di{
diB
delete inside bracesda{
daB
delete text inside braces (including braces)di[
delete inside bracketsda[
delete text inside brackets (including brackets)di"
delete inside quotesda"
delete a quoted text (including quotes)dit
delete inside tagdat
delete a tag (including tag)
ciw
same goes for other operators...
Repeat Last Change
.
Repeat the last change
문자 수정 커맨드
x
delete a character. Like dlX
delete character before the cursor. Like dhs
change a character. Like cl~
switch case of a character
Undo, Redo
u
Undo last changeCtrl-R
Redo last undo{count}u
undo last {count} changes
Insert Mode
i
go into insert mode before the cursora
go into insert mode after the cursor
I
go into insert mode at the beginning of a lineA
go into insert mode at the end of a line
o
insert new line below current line and go into insert modeO
insert new line above current line and go into insert mode
gi
go to the last place you left insert mode
Ctrl-H
delete last characterCtrl-W
delete last wordCtrl-U
delete last line
Visual Mode
v
go into character-wise visual modeV
go into line-wise visual modeCtrl-V
go into block-wise visual mode (to select rectangular blocks of text)
{trigger visual mode}{motion}{operator}
Visual mode operates in kind of the opposite way to normal mode.First you specify the motion to select text, and then you apply the operator
etc.
Operate on Next Search Match
{operator}gn
Apply operator on next match.
After using {op}gn, the dot commant repeats the last change on the next match. Woooot!
복사 및 붙여넣기
y{motion}
yank (copy) text covered by motionp
put (paste) after cursorP
paste before cursor
yy
copy lineY
copy line
yyp
duplicate lineddp
swap linesxp
swap characters
"ay{motion}
copy to register a"Ay{motion}
copy and append to register a"ap
paste from register a
"
unnamed register0
yank register1-9
delete registers[a-z]
named registers
Ctrl-R
a paste from register a when in Insert mode
창 분할
:sp {file}
Open file in a horizontal split:vsp {file}
Open file in a vertical splitCtrl-W S
Open same file in a horizontal splitCtrl-W V
Open same file in a vertical splitCtrl-W h
Move to split to the leftCtrl-W j
Move to split belowCtrl-W k
Move to split aboveCtrl-W l
Move to split to the right
탭 열기
:tabnew {file}
Open file in new tab:tabnext:tabn
Jump to next tab:tabprev:tabp
Jump to previous tab:tabonly:tabo
Close all other tabs
vim surround 관련 커맨드
ds
delete surroundings (e.g.)ds"
cs
change surroundings (e.g.)cs\*tem>
ys
add surroundings (e.g.)ysiw"
ds"
delete surrounding quotescs*tem>
change surrounding * for the<em>
tagysiw"
surround word under the cursor with quotes
S
In visual mode you can select some text, then type S to add surroundings. e.g. Stp> to wrap the selection in a<p>
tag
Reference
반응형
'개발 > 오늘 배운 지식' 카테고리의 다른 글
~211015 (0) | 2021.10.15 |
---|---|
[TIL]211002~04 (0) | 2021.10.05 |
210930 ~ 211001 (0) | 2021.10.02 |
20210929 (0) | 2021.09.30 |
20210928 (0) | 2021.09.29 |