vi基本操作

来源:互联网 发布:七天网络阅卷查分登陆 编辑:程序博客网 时间:2024/06/05 10:56

 vi 基本操作


1 locate 

0->row start 

$->row end 

w->word next 

b->word back (->sentence next )->sentence back 

ctrl+F->screen next 

ctrl+B->screen back 

:2->row 2 

2k->row up 2 


2 search 

/abc->search abc    

/ abc->search "abc"    

n->next N->back


3 save  

 :wq = ZZ 

!->ask 

:q!->quit without save  

 :w filename 

:e!->quit without save and restart VI


4 edit  

 i a->cursor 

 I A->row left and right  

o O->row up and down


5 delete 

6x 6X->cursor left and right   

dw->del word  

D->cursor row right del     

dd->del row   

cc=S->replace this row    

cw=R->replace word   

r->replace single alpha and return cmd     

s->replace this single alpha and insert 


6 recovery 

 :u=ctrl+r->recovery back to up state  

:U->recovery this sentence     


7 high level 

yy->cp sentence  

p->row down   

P->row up   

:!ls->ls and return but no sudo 


8 replace    

 :1,$s/\*/hello/g->replace all * with hello from 1 to end   

 :1,5s/misspelled/spelled corectly/gc->replace misspelled with spelled correctly from 1 to 5 and ask yes or no       g->row first or not  /g->row all 



9 row num

  :setnu 

0 0
原创粉丝点击