개발/오늘 배운 지식
[Vim + vscode] 단축키 모음(Vscode Vim Cheat Sheet)
Woogie2
2021. 10. 2. 19:25
반응형
다시 보기 위해 적는 vscode Vim extension 키 사용법.

Normal Mode
Motion
h커서를 왼쪽으로j커서 아래로k커서 위로l커서 오른쪽으로iInsert mode<ESC><Ctrl-C><Ctrl-[>Go to Normal mode
단어별 이동
word는 괄호 문자 포함 X, WORD는 포함 O
wmove to the beginning of next wordbmove to the beginning of the previous wordemove to the end of the next wordgemove to the end of the previous word
Wmove to the beginning of next WORDBmove to the beginning of the previous WORDEmove to the end of the next WORDgEmove 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}
수평 방향으로 커서 이동(단일 줄에서)
줄의 앞과 끝
0Moves 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-Dlets you move down half a page by scrolling the pageCTRL-Ulets 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
nGo to next matchNGo to previous match
count를 활용해서 더욱 빠르게.
{count}{motion}Repeat {motion} {count} times
2wJump to second word4f"Jump to fourth occurrence of the " character3/cucumberJump to third match of "cucumber"
Move Semantically
gdGo to definition (of the word under the cursor)gfGo to file (for file under the cursor)
이외의 core motion들
ggGo to the top of the file{line}ggGo to {line}GGo 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
ddeletecchangeyyank (copy)pp (paste)g~switch case>shift right<shift left=format
LineWise
dddelete a lineccchange a lineyyyank (copy) a lineg~~switch case of a line>>shift line right<<shift lineleft==format line
Capital Case operator더 Strong한 ver
Ddelete from cursor to the end of the lineCchange from cursor to the end of the lineYyank (copy) a line. Like yyPput (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
diwdelete inner worddawdelete a worddisdelete inner sentencedasdelete a sentencedipdelete inner paragraphdapdelete a paragraphdi(dibdelete inside parenthesesda(dabdelete text inside parentheses (including parentheses)di{diBdelete inside bracesda{daBdelete 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)ditdelete inside tagdatdelete a tag (including tag)
ciwsame goes for other operators...
Repeat Last Change
.Repeat the last change
문자 수정 커맨드
xdelete a character. Like dlXdelete character before the cursor. Like dhschange a character. Like cl~switch case of a character
Undo, Redo
uUndo last changeCtrl-RRedo last undo{count}uundo last {count} changes
Insert Mode
igo into insert mode before the cursorago into insert mode after the cursor
Igo into insert mode at the beginning of a lineAgo into insert mode at the end of a line
oinsert new line below current line and go into insert modeOinsert new line above current line and go into insert mode
gigo to the last place you left insert mode
Ctrl-Hdelete last characterCtrl-Wdelete last wordCtrl-Udelete last line
Visual Mode
vgo into character-wise visual modeVgo into line-wise visual modeCtrl-Vgo 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}gnApply 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 motionpput (paste) after cursorPpaste before cursor
yycopy lineYcopy line
yypduplicate lineddpswap linesxpswap characters
"ay{motion}copy to register a"Ay{motion}copy and append to register a"appaste from register a
"unnamed register0yank register1-9delete registers[a-z]named registers
Ctrl-Ra 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 SOpen same file in a horizontal splitCtrl-W VOpen same file in a vertical splitCtrl-W hMove to split to the leftCtrl-W jMove to split belowCtrl-W kMove to split aboveCtrl-W lMove to split to the right
탭 열기
:tabnew {file}Open file in new tab:tabnext:tabnJump to next tab:tabprev:tabpJump to previous tab:tabonly:taboClose all other tabs
vim surround 관련 커맨드
dsdelete surroundings (e.g.)ds"cschange surroundings (e.g.)cs\*tem>ysadd surroundings (e.g.)ysiw"
ds"delete surrounding quotescs*tem>change surrounding * for the<em>tagysiw"surround word under the cursor with quotes
SIn 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
반응형