rche 033----unit 11 -advanced uses of the vi editors

unit 11 -advanced uses of the vi editors

.file repositioning
.screen repositioning
.filtering
.ex mode:search and replace
.advanced reading and saving
.configuring vi======================================
           
           file repositioning ===================
          
    .G    go to last line in file
    .1G   go to first line in file
   
    .<ctrl-d>  go down half a screen
    .<ctrl-u>  go up half a screen  
      
    .H  go to first line on screen (high)
    .M  go to middle line on screen(middle)
    .L  go to last line on screen(low)
   
    .Z<Enter>  make current line first line on screen
    .z-        make current line last  line on screen
   
    filtering
           .the data in the file can be used as input
           .examples:
              .!!S -l=====插入到vi中
  total 1416
---------x 1 root root   6993 May 24 15:19 acpid
-rw------- 1 root root 306525 Apr 27 21:49 anaconda.log
-rw------- 1 root root  14904 Apr 27 21:49 anaconda.syslog
drwxr-x--- 2 root root   4096 Apr 27 21:53 audit
-rw------- 1 root root      0 May 24 05:11 boot.log
-rw------- 1 root root      0 May 17 06:53 boot.log.1
-rw------- 1 root root      0 May 15 08:48 boot.log.2
-rw------- 1 root root      0 Apr 27 21:53 boot.log.3
-rw------- 1 root utmp   5376 May 24 15:20 btmp
drwxr-xr-x 2 root root   4096 Nov 12  2007 conman
drwxr-xr-x 2 root root   4096 Nov 12  2007 conman.old
-rw------- 1 root root    701 May 24 18:01 cron
-rw------- 1 root root   7647 May 24 05:11 cron.1
-rw------- 1 root root   1400 May 17 06:53 cron.2
-rw------- 1 root root   7791 May 15 08:48 cron.3
drwxr-xr-x 2 lp   sys    4096 May 24 05:11 cups
-rw-r--r-- 1 root root  13205 May 24 15:18 dmesg
-rw------- 1 root root  12096 May 18 13:43 faillog
-rw-r--r-- 1 root root 147168 May 24 16:02 lastlog
drwxr-xr-x 2 root root   4096 Apr 27 21:43 mail
-rw------- 1 root root    365 May 24 15:19 maillog
-rw------- 1 root root  11440 May 24 18:08 maillog.1
-rw------- 1 root root   1596 May 17 06:53 maillog.2
:.!ls -l           
              .!!date
Sun May 24 18:10:55 CST 2009========插入时间戳
---------x 1 root root   6993 May 24 15:19 acpid
-rw------- 1 root root 306525 Apr 27 21:49 anaconda.log
-rw------- 1 root root  14904 Apr 27 21:49 anaconda.syslog
drwxr-x--- 2 root root   4096 Apr 27 21:53 audit
-rw------- 1 root root      0 May 24 05:11 boot.log
-rw------- 1 root root      0 May 17 06:53 boot.log.1
-rw------- 1 root root      0 May 15 08:48 boot.log.2
:.!date             
              .!}sort ========将资料排序
             
             
              .!}fmt -w60=====设定段落的字为60个字,就换行
             
   April 2009
Su Mo Tu We Th Fr Sa
          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
total 88
-rw------- 1 root root     0 Apr 28 15:04 1.txt
-rw------- 1 root root   870 Apr 27 21:49 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Apr 28 17:14 doc1
-rw-r--r-- 1 root root 10240 Apr 27 23:34 doc1.tar
-rw-r--r-- 1 root root   236 Apr 27 23:36 doc1.tar.bz2
-rw-r--r-- 1 root root   239 Apr 27 23:35 doc1.tar.gz
-rw-r--r-- 1 root root 20048 Apr 27 21:49 install.log
-rw-r--r-- 1 root root  3049 Apr 27 21:48 install.log.syslog
-rwSr-Sr-- 1 root root     0 Apr 28 15:03 test1.txt
~
~
~:.!ls -l 
 :.!date
   
   
   
    ex mode:search and replace
         .sed sytle search and replace
         .different default addressing rule
            .no address         current line only
            .1,10               change line through 10
            .1,$ or %           for changes to entire file
            ..,.+10   

本文出自 “www.51cto.com” 博客,谢绝转载!

你可能感兴趣的:(linux,vi,休闲,033,rche)