4.vim帮助文档

发布时间 2023-07-29 23:49:15作者: 人间丶迷走

1.0 refernce manual

  • Chinese reference manual

    https://yianwillis.github.io/vimcdoc/doc/help.html
    
  • ON-LINE HELP :help

    # search for help
    :help
    :help keyword
    
    # example
    :help inserting
    

1.1 basic modes

  • start Normal mode

    # vim file.txt
    Since you have just started Vim it will be in Normal mode.
    
    # <Esc>
    To get back to Normal mode, no matter what mode you are in, press the <Esc> key.
    
  • start Insert mode

    # These commands are used to start inserting text.
                        *a*  *A*
    a   Append text after the cursor [count] times.
    A   Append text at the end of the line [count] times.
                        *i*  *I*
    i   Insert text before the cursor [count] times.
    I   Insert text before the first non-blank in the line [count] times.
                        *o*  *O*
    o   Begin a new line below the cursor and insert text, repeat [count] times.
    O   Begin a new line above the cursor and insert text, repeat [count] times.
    
    # <Esc>
    You can end insert mode with <Esc>.
    

1.2 Normal mode

  • Moving around

    # *03.1*  Word movement
    The "w" command moves to the start of the next word.
    The "b" command moves backward to the start of the previous word.
    
            This is a line with example text
            x-->-->->----------------->
            w  w  w    3w
    
            This is a line with example text
            <----<--<-<---------<--x
            b   b b    2b      b
    
    # *03.2*  Moving to the start or end of a line
    The "$" command moves the cursor to the end of a line. (same as <End> key)
    
    The "0" command (zero) moves to the very first character of the line. (same as <Home> key)
    The "^" command moves to the first non-blank character of the line.
    
                    ^
                <-----------x
            .....This is a line with example text
            <----------------x   x-------------->
                    0                  $
    
    (the "....." indicates blanks here)
    
    # *03.3*  Moving to a character
    The "fh" command searches forward in the line for the single character 'h'.
    
            To err is human.  To really foul up you need a computer.
            ---------->--------------->
                fh           fy
    
    The "F" command searches to the left:
    
            To err is human.  To really foul up you need a computer.
                    <---------------------
                                Fh
    
    The "3fu" command searches forward to the third character 'u' (the "u" of "you").
    
            To err is human.  To really foul up you need a computer.
                            -------------------->
                                    3fu
    
    # *03.4*  Matching a parenthesis
    the "%" command moves to the matching paren.
    If the cursor is on a "(" it will move to the matching ")". This also works for [] and {} pairs.
    
                                %
                            <----->
                    if (a == (b * c) / d)
                    <---------------->
                                %
    
    # *03.5*  Moving to a specific line
                # whole file #
    "gg" positions you at the start of a file.
    "G"  positions you at the end of the file.
    "7G" puts you on line 7.
    
                |   first line of a file   ^
                |   text text text text    |
                |   text text text text    |  gg
            7G  |   text text text text    |
                |   text text text text
                |   text text text text
                V   line 7777 7777 line    |
                    text text text text    |  G
                    text text text text    |
                    last line of a file    V
    
                # current page #
    "H" stands for Home, "M" for Middle and "L" for Last.
    
                            +---------------------------+
                    H -->   | text sample text          |
                            | sample text               |
                            | text sample text          |
                            | sample text               |
                    M -->   | text sample text          |
                            | sample text               |
                            | text sample text          |
                            | sample text               |
                    L -->   | text sample text          |
                            +---------------------------+
    
    # *03.7*  Scrolling around
    The CTRL-U command scrolls down half a screen of text.(DOWN)
    The CTRL-D command scrolls  up  half a screen of text.(UP)
    
                                        +----------------+
                                        | some text      |
                                        | some text      |
                                        | some text      |
            +---------------+              | some text      |
            | some text     |  CTRL-U  --> |                |
            |               |              | 123456         |
            | 123456        |              +----------------+
            | 7890          |
            |               |              +----------------+
            | example       |  CTRL-D -->  | 7890           |
            +---------------+              |                |
                                        | example        |
                                        | example        |
                                        | example        |
                                        | example        |
                                        +----------------+
    
    The CTRL-F command scrolls forward by a whole screen.(FORWARD)
    The CTRL-B command scrolls backward by a whole screen.(BACKWARD)
    
    
    # *03.8*  Simple searches
    the "/keyword" command to find the word 'keyword'.(The "?" command works like "/" but searches backwards)
        the "n" command finds next keyword.
        the "N" command finds backward.
        IGNORING CASE
            If you don''t care about upper or lowercase in a word, set the 'ignorecase' option:
            :set ignorecase
            :set noignorecase
        SEARCHING FOR WHOLE WORDS
            "/the"      soothe there the
            "/the\>"    soothe the
            "/\<the\>"  the
        HIGHLIGHTING MATCHES
            :set hlsearch
            :set nohlsearch
    
    
    # *03.9*  Simple search patterns
    The Vim editor uses regular expressions to specify what to search for.
    
            the solder holding one of the chips melted and the
            xxx                       xxx                  xxx
    
    Using "/the$" we find this match:
    
            the solder holding one of the chips melted and the
                                                        xxx
    
    And with "/^the" we find this one:
            the solder holding one of the chips melted and the
            xxx