Vim Shortcuts
Vim Shortcuts
Vim Shortcuts Complete Guide: Secrets of Efficient Text Editing
Navigation
Basic Movement
^: Move to the first non-blank character of the line0: Move to the absolute beginning of the line (including spaces)$: Move to the end of the linegg: Move to the first line of the fileG: Move to the last line of the file
Advanced Movement
{number}G: Directly move to a specific line number (e.g.,10Gmoves to the 10th line)H: Move to the top of the screenM: Move to the middle of the screenL: Move to the bottom of the screen
Editing
Substitution
%s/search_word/replace_word/option: Replace words throughout the entire file
Substitution Options
i: Ignore caseg: Replace all matches in a linec: Show confirmation prompt before replacing
Examples:
%s/hello/world/gi: Replace all ‘hello’ with ‘world’ (case-insensitive)
Text Insertion and Modification
i: Start insert mode at current cursor positionI: Start insert mode at the first non-blank character of the linea: Start insert mode after the current cursor positionA: Start insert mode at the end of the lineo: Open a new line below and start insert modeO: Open a new line above and start insert mode
Deletion and Copying
dd: Delete current linedw: Delete wordD: Delete from cursor to end of lineyy: Copy current linep: Paste copied content after cursorP: Paste copied content before cursor
Advanced Features
Undo and Redo
u: UndoCtrl + r: Redo
Configuration-related
:%retab: Convert tabs to spaces (or vice versa)set nu: Display line numbersset nonu: Hide line numbers
Visual Mode
v: Start character-wise visual modeV: Start line-wise visual modeCtrl + v: Start block visual mode
Tips and Tricks
- Most Vim commands can be used with numbers
- Example:
3dddeletes 3 lines
- Example:
- Save and Exit Commands
:w: Save:q: Quit:wq: Save and Quit
Vim 단축키 완전 가이드: 효율적인 텍스트 편집의 비밀
이동 (Navigation)
기본 이동
^: 현재 줄의 첫 번째 비어있지 않은 문자로 이동0: 줄의 가장 처음으로 이동 (공백 포함)$: 줄의 마지막으로 이동gg: 파일의 첫 번째 줄로 이동G: 파일의 마지막 줄로 이동
고급 이동
{number}G: 특정 줄 번호로 직접 이동 (예:10G는 10번째 줄로 이동)H: 화면의 맨 위로 이동M: 화면의 중간으로 이동L: 화면의 맨 아래로 이동
편집 (Editing)
치환 (Substitution)
%s/찾을단어/바꿀단어/옵션: 파일 전체에서 단어 치환
치환 옵션
i: 대소문자 무시g: 한 줄에서 모든 일치 항목 바꾸기c: 바꾸기 전 확인 창 보여주기
예시:
%s/hello/world/gi: 모든 ‘hello’를 ‘world’로 대소문자 구분 없이 바꾸기
텍스트 삽입 및 수정
i: 현재 커서 위치에 삽입 모드 시작I: 줄의 첫 번째 비어있지 않은 문자 앞에 삽입 모드 시작a: 현재 커서 다음 위치에 삽입 모드 시작A: 줄의 끝에 삽입 모드 시작o: 현재 줄 아래에 새 줄 추가 후 삽입 모드 시작O: 현재 줄 위에 새 줄 추가 후 삽입 모드 시작
삭제 및 복사
dd: 현재 줄 삭제dw: 단어 삭제D: 현재 커서부터 줄 끝까지 삭제yy: 현재 줄 복사p: 복사한 내용 붙여넣기 (커서 다음)P: 복사한 내용 붙여넣기 (커서 앞)
고급 기능
실행 취소 및 다시 실행
u: 실행 취소 (Undo)Ctrl + r: 다시 실행 (Redo)
설정 관련
:%retab: 탭을 스페이스로 변환 (또는 그 반대)set nu: 줄 번호 표시set nonu: 줄 번호 숨기기
비주얼 모드
v: 문자 단위 비주얼 모드 시작V: 줄 단위 비주얼 모드 시작Ctrl + v: 블록 비주얼 모드 시작
팁과 트릭
- 대부분의 Vim 명령어는 숫자와 함께 사용 가능
- 예:
3dd는 3줄 삭제
- 예:
- 저장 및 종료 명령어
:w: 저장:q: 종료:wq: 저장 후 종료
This post is licensed under CC BY 4.0 by the author.