//vim 설치
$sudo apt -get install vim
$vi --version
//new file start
$ vi hello.c
(file)
//edit
i
//done typing
<Esc>
//save the file and quit vi
:wq
Model of vi : 3-state finite machines
start with.... Command mode
Insert mode - a, i , o
Last-Line mode - ESC, execution
Insert mode
a - 가장 최근 문자 이후 point
i - 가장 최근 문자 이전 point
o - 가장 최근 문자 이후 new line 생성
Last line mode
- /, ?, : 을 누르고 시작해야만 한다
/ - search forward . type 과 같은 패턴 검색 n키 누르면 다음을 검색
? - search backward
// 검색 후 대체
:1, $s/int/char/
// 1~마지막까지 대체해
// int를 char로
: - expect a line command
//go to the line
:#
//write, 파일이름 변경
:w (name)
//종료.. 수정했었다면 저장하라는 문구가 뜬다
:q
//저장 없이 종료
:q!
//저장 후 종료
:wq
//라인번호 보이기
:set number
:se nu
//라인번호 안보이기
:set nonumber
:se nonu
//인덴트 설정
:set autoindent
:se ai
//tap사이즈 설정
:set tapstop=4
:se ts=4
Command
커서 움직이기
//단어 단위
w //move one word forward
b //move one word backward
//character 단위
^ //Move to first character on line
$ //Move to last character on line
//라인단위
j //Move to next line ex) 10j 10줄 아래로
k //Move to previous line
//파일단위
gg //Move to first line of file
G //Move to last line of file
스크린 움직이기
Ctrl-d //scroll down
Ctrl-u //scroll up
텍스트
//copy pasting
yw //버퍼에 있는 가장 최근 word 복사
yy //최근 line 복사 ex)2yy 2line copy
p //붙여넣기
//delete
x //current character
dw //word
dd //line ex)5dd 5lines
//undo
u
'Major S-T-U-D-Y > System Programming' 카테고리의 다른 글
9. Derived type - array, pointer, and structure (1) (1) | 2024.11.12 |
---|---|
8. Procedure Call and Stack (0) | 2024.11.12 |
GNU make (1) | 2024.10.18 |
4. Machine level representation basics (1) (0) | 2024.10.15 |
1. A Tour of Computer Systems (1) (0) | 2024.09.13 |