1 / 18

제 5 강

제 5 강. editing program files with vi 기본적인 Linux commands. vi. UNIX 의 기본 편집기 Windows 의 notepad 에 해당 Much more powerful 명령 모드 ( 기본 모드 ) 와 입력 모드 명령 모드에서는 search, replace, 이동 등 입력 모드에서는 글자의 입력 Linux 에서는 vi-compatible 한 vim 이 사용됨 . (free). 시작과 끝. 앞으로는 Enter key 표시는 하지 않음. $ vi

vala
Download Presentation

제 5 강

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 제 5 강 editing program files with vi 기본적인 Linux commands

  2. vi • UNIX의 기본 편집기 • Windows의 notepad에 해당 • Much more powerful • 명령 모드(기본 모드)와 입력 모드 • 명령 모드에서는 search, replace, 이동 등 • 입력 모드에서는 글자의 입력 • Linux에서는 vi-compatible한 vim이 사용됨. (free)

  3. 시작과 끝 앞으로는 Enter key 표시는 하지 않음 • $ vi • $ vi filename • 끝내기 • :wq - 저장하고 빠져나오기:w - 저장하기:w filename - filename으로 저장:q! - 저장하지 않았어도 강제로 종료 Enter Enter

  4. 실습 $vi hello (입력 모드) (type)i (입력 모드) I hate black boxes. One of my goals in writing this book was to illuminate some of those black boxes that are so popular in information security books today. :wq

  5. 모드의 전환 • 명령 모드로: • 최초 수행, 입력 모드에서 ESC 키 • 입력 모드로:i 커서 앞에서a 커서 뒤o 다음줄에 삽입O 앞줄에 삽입

  6. 명령 모드에서의 이동 • ←↓↑→ : 한글자씩 이동 • h j k l : 위와 같음 • w : word forward • b : word backward • e : end of word • ^f : one page forward (끝 쪽으로) • ^b : one page backward (앞쪽으로) • ^d : half page forward(아래쪽(down)) • ^u : half page backward(위쪽(up)) • <숫자>G : Go to line XX

  7. 추가적 입력 모드 • cw - change word • cc - change line • s – change a character to anything • <숫자>s – 여러개의 글자를 다른 글자로 (예: 2s, 3s, 7s … )

  8. Search • /<pattern><enter> : search for pattern • n : repeat search • N : repeat search, but reverse direction • ?<pattern><enter> : search for pattern backward

  9. substitution • :<lines>s/<pattern>/<new text>/[g] • 예:%s/she/he/ • 문서 전체(%)에서 she를 he로. 단 한 줄에 둘 이상이면 첫째것만. %s/she/he/g 이면 모든 것. :10,15s/she/they/g - 10행부터 15행까지 she를 they로 치환

  10. Yank and Paste • <줄수>yy : yank (= copy) • p : 커서 있는 줄 다음에 paste • dd : 현재 줄을 cut • 3dd: 현재줄 포함 3줄을 cut • dw : 현재 단어를 cut • 4dw : 4단어를 cut • :12,23d : 12째 줄부터 23째 줄까지 cut • :12,24y : 12째 줄부터 24째 줄까지 copy

  11. 명령의 반복, 취소 • u – undo last command • ^r - redo last undone command • . - repeat last command

  12. 기타 유용한 명령 • ~ 대소문자 변경 • R .. Esc 삽입 대신 치환

  13. Linux Directory [swhong@turing ~] pwd /home/swhong [swhong@turing ~] ls hello /home/swhong hello hw1 hw2 ans.c hw.c

  14. Directory 관련 명령어 • .. • 부모 디렉토리 • ../ans.c • . • 현재 디렉토리(working directory) • ~ • Home directory

  15. Directory 관련 명령어 • cd • Change directory • pwd • Print working directory • mkdir • Make a new directory • rmdir • Remove directory • mv • Rename a directory • ls • List contents of directory

  16. lab05_01 • Run script • vimtutor • save as a local file 'tutor' • run vi tutor • do as directed • quit script • submit typescript

  17. setting • 홈 directory 또는 current directory의 “.exrc” file • set hls (highlight search, 반대는 nohls) • set number (nu, 줄 번호, 반대는 nonumber) • set autoindent (ai, 자동 들여쓰기, noai) • set ts=4 (tab 하나의 크기 결정) • syntax on (또는 off)  C 언어 구문에 따라 색깔 • 해당 session에만 사용하려면 :set XXX

  18. 제 5 강 끝. vi

More Related