Unix Shell -- VI

Vi command:

x/X: delete current charactor

ctrl+u: cancel the last operation

ctrl+F/B: go to the page top/bottom

k/l: move

dd: delete the current line

+: go to the next line

E/e: go to the next phrase(word)

D/d: delete to the end of line(eol)

q!: quit without saving

wq: save and quit

ZZ: save and quit

ZX: quit without saving

n: next occurence

%\x\y\g replace 'x' with 'y' in file

vi -r <filename>: recover the file(last time exit without saving)

{/}: go to the beginning or end of the paragraph

&: make the program(command) run in background, if you use this command, you will get a processid,
so you can view the status of the program(command) by using 'fg processid' which brings it go foreground.

/yourstring: find yourstring in the file, then you can user 'n' to go to the next occurence of the searching.


--------------------------------------------------------------------------
½â¾ö vi±à¼­Ê±Òì³£Í˳öºóµÄÌáʾ
2009Äê03ÔÂ19ÈÕ ÐÇÆÚËÄ ÏÂÎç 04:48
E325: ATTENTION
Found a swap file by the name "filename.swp"
          owned by: root   dated: Wed Mar 18 10:58:30 2009
         file name: /han/ok.sh
          modified: no
         user name: root   host name: localhost.localdomain
        process ID: 28676 (still running)
While opening file "ok.sh"
             dated: Wed Mar 18 10:56:50 2009

(1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.

(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r ok.sh"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".ok.sh.swp"
    to avoid this message.
"ok.sh" 4L, 57C
Hit ENTER or type command to continue

ÕâÊÇÓÉÓÚÔڱ༭¸ÃÎļþµÄʱºòÒì³£Í˳öÁË£¬ÒòΪviÔڱ༭Îļþʱ»á´´½¨Ò»¸ö½»»»Îļþswap fileÒÔ±£Ö¤ÎļþµÄ°²È«ÐÔ

µ±ÏµÍ³ÖØÆôºóvi ÌáʾÎÒÃÇÊÇ·ñ»Ö¸´ÒÔÇ°µÄÎļþ¡£Èç¹ûÐèÒª»Ö¸´£¬¿ÉÒÔÀûÓÃvi -r filename.swap ---->> È»ºó´òðºÅ½øÈëÃüÁîģʽ£¬write newfilenameÒÔÁí´æ½»»»Îļþ¡£


È¥µôÉÏÃæµÄÌáʾ£ºÎÒÃÇÐèҪɾ³ý¸ÃswapÎļþ£ºrm -f filename.swap
 



發佈了45 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章