zoukankan      html  css  js  c++  java
  • [转]vi command summary

      1 The following tables contain all the basic vi commands. 
      2 
      3 *Starting vi*
      4 
      5 Command                       Description
      6 vi file                       start at line 1 of file
      7 vi +n file                    start at line n of file
      8 vi + file                     start at last line of file
      9 vi +/pattern file             start at pattern in file
     10 vi -r file                    recover file after a system crash
     11 
     12 *Saving files and quitting vi*
     13  
     14 Command                       Description
     15 :e file                       edit file (save current file with *:w* first)
     16 :w                            save (write out) the file being edited
     17 :w file                       save as file
     18 :w! fil e                     save as an existing file
     19 :q                            quit *vi*
     20 :wq                           save the file and quit *vi*
     21 :x                            save the file if it has changed and quit *vi*
     22 :q!                           quit *vi* without saving changes
     23 
     24 *Moving the cursor*
     25 
     26 Keys pressed                  Effect
     27 h                             left one character
     28 l or <Space>                  right one character
     29 k                             up one line
     30 j or <Enter>                  down one line
     31 b                             left one word
     32 w                             right one word
     33 (                             start of sentence
     34 )                             end of sentence
     35 {                             start of paragraph
     36 }                             end of paragraph
     37 1G                            top of file
     38 nG                            line n
     39 G                             end of file
     40 <Ctrl>W                       first character of insertion
     41 <Ctrl>U                       up ½ screen
     42 <Ctrl>D                       down ½ screen
     43 <Ctrl>B                       up one screen
     44 <Ctrl>F                       down one screen
     45 
     46 *Inserting text*
     47     
     48 Keys pressed                  Text inserted
     49 a                             after the cursor
     50 A                             after last character on the line
     51 i                             before the cursor
     52 I                             before first character on the line
     53 o                             open line below current line
     54 O                             open line above current line
     55 
     56 *Changing and replacing text*
     57 
     58 Keys pressed                  Text changed or replaced
     59 cw                            word
     60 3cw                           three words
     61 cc                            current line
     62 5cc                           five lines
     63 r                             current character only
     64 R                             current character and those to its right
     65 s                             current character
     66 S                             current line
     67 ~                             switch between lowercase and uppercase
     68 
     69 *Deleting text*
     70 
     71 Keys pressed                  Text deleted
     72 x                             character under cursor
     73 12x                           12 characters
     74 X                             character to left of cursor
     75 dw                            word
     76 3dw                           three words
     77 d0                            to beginning of line
     78 d$                            to end of line
     79 dd                            current line
     80 5dd                           five lines
     81 d{                            to beginning of paragraph
     82 d}                            to end of paragraph
     83 :1,. d                        to beginning of file
     84 :.,$ d                        to end of file
     85 :1,$ d                        whole file
     86 
     87 *Using markers and buffers*
     88 
     89 Command                       Description
     90 mf                            set marker named ``f''
     91 `f                            go to marker ``f''
     92 ´f                            go to start of line containing marker ``f''
     93 "s12yy                        copy 12 lines into buffer ``s''
     94 "ty}                          copy text from cursor to end of paragraph into buffer ``t''
     95 "ly1G                         copy text from cursor to top of file into buffer ``l''
     96 "kd`f                         cut text from cursor up to marker ``f'' into buffer ``k''
     97 "kp                           paste buffer ``k'' into text
     98 
     99 *Searching for text*
    100 
    101 Search                        Finds
    102 /and                          next occurrence of ``and'', for example, ``and'', ``stand'',``grand''
    103 ?and                          previous occurrence of ``and''
    104 /^The                         next line that starts with ``The'', for example, ``The'',``Then'', ``There''
    105 /^The>                       next line that starts with the word ``The''
    106 /end$                         next line that ends with ``end''
    107 /[bB]ox                       next occurrence of ``box'' or ``Box''
    108 n                             repeat the most recent search, in the same direction
    109 N                             repeat the most recent search, in the opposite direction
    110 
    111 *Searching for and replacing text*
    112 
    113 Command                        Description
    114 :s/pear/peach/g                replace all occurrences of ``pear'' with ``peach'' on current line
    115 :/orange/s//lemon/g            change all occurrences of ``orange'' into ``lemon'' on next line containing ``orange''
    116 :.,$/<file/directory/g        replace all words starting with ``file'' by ``directory'' on every line from current line onward, for example,``filename'' becomes ``directoryname''
    117 :g/one/s//1/g                  replace every occurrence of ``one'' with 1, for example,``oneself'' becomes ``1self'', ``someone'' becomes ``some1''
    118 
    119 *Matching patterns of text*
    120 
    121 Expression                     Matches
    122 .                              any single character
    123 *                              zero or more of the previous expression
    124 .*                             zero or more arbitrary characters
    125 <                             beginning of a word
    126 >                             end of a word
    127                               quote a special character
    128 *                             the character ``*''
    129 ^                              beginning of a line
    130 $                              end of a line
    131 [set]                          one character from a set of characters
    132 [XYZ]                          one of the characters ``X'', ``Y'', or ``Z''
    133 [[:upper:]][[:lower:]]*        one uppercase character followed by any number of lowercase characters
    134 [^set]                         one character not from a set of characters
    135 [^XYZ[:digit:]]                any character except ``X'', ``Y'', ``Z'', or a numeric digit
    136 
    137 *Options to the :set command*
    138 
    139 Option                         Effect
    140 all                            list settings of all options
    141 ignorecase                     ignore case in searches
    142 list                           display <Tab> and end-of-line characters
    143 mesg                           display messages sent to your terminal
    144 nowrapscan                     prevent searches from wrapping round the end or beginning ofa file
    145 number                         display line numbers
    146 report=5                       warn if five or more lines are changed by command
    147 term=ansi                      set terminal type to ``ansi''
    148 terse                          shorten error messages
    149 warn                           display ``[No write since last change]'' on shell escape if filehas not been saved
  • 相关阅读:
    如何保持页脚始终在页面底部
    CSS自适应宽度圆角按钮
    ACM1004
    java输出格式
    北大ACM1001题Exponentiation(求高精度幂)
    深入理解sizeof
    java之类BigDecimal
    ACM1003
    ACM1005
    C的输出格式printf
  • 原文地址:https://www.cnblogs.com/pdev/p/4105492.html
Copyright © 2011-2022 走看看