티스토리 뷰

Code Story

Programming Tip <VI Editor>

chauchau0 2006. 12. 1. 10:56

예전엔 주로 VC로 윈도우 프로그램을 만들다 요즘 리눅스 프로그램을 많이 하는데
하면서 느끼는 부분은 기존에 있던 편리하던 디버깅 기능이나 기타 여러 잡다한 기능들이
알아보면 모두 리눅스에도 있다는거... 정말 없는건 없다.

GDB도 그렇고 VI도 그렇고 이 두 개면 모든걸 다 할 수 있을 듯.

-------------------------------------------------------------------
VI TIP들 정리

Cursor Movements
   One character
       h    - left
       j    - down
       k    - up
       l    - right
   One word
       w    - next word
       b    - previous word
   To ends of line
       $    - end of the line
       ^    - beginning of the line
   To a specified line
       nG    - line number n
       G    - last line

Scrolling
   One line
       Ctrl-Y    - up one line
       Ctrl-E    - down one line
   Several lines
       Ctrl-U    - up
       Ctrl-N    - down
   Full screenfull
       Ctrl-F    - forward
       Ctrl-B    - backward

Adding Text
   Inserting text
       i    - before the cursor
       I    - beginning of the line
       a    - after the cursor
       A    - end of the line
   Opening a new line
       o    - below the line of the cursor
       O    - abive the line of the cursor

Deleting Text
   One character
       x    - under the cursor
   One word
       dw    - from the cursor to end of the word
   Deleting lines
       dd    - one line
       ndd    - n lines
   To end of line
       D    - from the cursor to the end of the line

Changing Text
   r    - one character
   cw    - one word
   R    - Unlimited
   J    - joins current and below line

Correcting Mistakes
   u    - undo

Redrawing the Screen
   Ctrl-L

Writing Out the Buffer File and Leaving
   :w
   :q
   :wq
   :q!

Reading and Writing Files
   :r
   :w

Autoindent
   :set ai        - turn on
   :set noai    - turn off

Searching for Text
   /pattern
   n    - next
   N    - previous

Marking Text
   ma    - mark
   'a    - move to a

Deleting Large Pieces of Text
   d'a    - delete from the cursor to the mark a
   dG    - delete from the cursor to the end of the file
   d1G    - delete from the cursor to the beginning of the file

Copying Text
   yw    - copy the word
   yy    - copy the line
   nyy    - copy the n lines
   y'a    - copy from the cursor to the mark a
   p    - paste

Copying Text into Named Buffers
   "xy'a    - copy from the cursor to the mark a into buffer x
   "xp    - paste

Recovering Lost Text
   "1p    - paste the deletion buffer 1

Repeating a Command
   .

Switching the editor
   :e destination-file

Substitute
   :s/old/new/g  - substitute 'new' for 'old'

Tab 지우기
   :%s/^I/ /g

자동 완성 기능
   Ctrl-N


'Code Story' 카테고리의 다른 글

[펌] 메모리릭이여, 안녕!  (0) 2006.12.07
ctags 와 vim 친구들  (0) 2006.12.04
TAR  (0) 2006.11.14
Program Library HOWTO  (0) 2006.11.10
[펌] rsync란  (0) 2006.11.07
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함