美文网首页
Moving In A File

Moving In A File

作者: 一口亅 | 来源:发表于2021-05-07 23:13 被阅读0次

    Word Navigation

    w     Move forward to the beginning of the next word
    W     Move forward to the beginning of the next WORD
    e     Move forward one word to the end of the next word
    E     Move forward one word to the end of the next WORD
    b     Move backward to beginning of the previous word
    B     Move backward to beginning of the previous WORD
    ge    Move backward to end of the previous word
    gE    Move backward to end of the previous WORD
    

    注:word和WORD的区别

    • 都由非空白字符分隔
    • word是仅包含A- za - z0 -9_的字符序列
    • WORD是除空格(空格意味着空格、制表符和EOL)以外的所有字符的序列。

    Current Line Navigation

    0     Go to the first character in the current line
    ^     Go to the first nonblank char in the current line
    g_    Go to the last non-blank char in the current line
    $     Go to the last char in the current line
    n|    Go the column n in the current line
    
    f    Search forward for a match in the same line
    F    Search backward for a match in the same line
    t    Search forward for a match in the same line, stopping before match
    T    Search backward for a match in the same line, stopping before match
    ;    Repeat the last search in the same line using the same direction
    ,    Repeat the last search in the same line using the opposite direction
    

    Sentence And Paragraph Navigation

    (    Jump to the previous sentence
    )    Jump to the next sentence
    
    {    Jump to the previous paragraph
    }    Jump to the next paragraph
    

    Match Navigation

    %    Navigate to another match, usually works for (), [], {}
    

    Line Number Navigation

    gg    Go to the first line
    G     Go to the last line
    nG    Go to line n
    n%    Go to n% in file
    Ctrl-g     see total lines in a file
    

    Scrolling

    Ctrl-E    Scroll down a line
    Ctrl-D    Scroll down half screen
    Ctrl-F    Scroll down whole screen
    Ctrl-Y    Scroll up a line
    Ctrl-U    Scroll up half screen
    Ctrl-B    Scroll up whole screen
    
    zt    Bring the current line near the top of your screen
    zz    Bring the current line to the middle of your screen
    zb    Bring the current line near the bottom of your screen
    

    Search Navigation

    /    Search forward for a match
    ?    Search backward for a match
    n    Repeat last search in same direction of previous search
    N    Repeat last search in opposite direction of previous search
    
    set hlsearch       enable search highlight
    set incsearch     增量搜索,这将在输入时突出显示模式。
    

    默认情况下,匹配的短语将一直高亮显示,直到你搜索另一个短语。这很快就会变成一种烦恼.
    To disable highlight, you can run :nohlsearch.

    *     Search for whole word under cursor forward
    #     Search for whole word under cursor backward
    g*    Search for word under cursor forward
    g#    Search for word under cursor backward
    

    / 和 *的区别:

    • /可以找出所有含该字符的,即使该字符属于一个更大字符的一部分。但是*只会找这个单词,如果属于别的单词一部分,将跳过
    • *one will be the same as if you had done /<one>

    Marking Position

    ma    Mark position with mark "a"
    `a    Jump to line and column "a"
    'a    Jump to line "a"
    小写字母是局部标记,大写字母是全局标记
    
    :marks    view all marks
    
    ''    Jump back to the last line in current buffer before jump
    ``    Jump back to the last position in current buffer before jump
    `[    Jump to beginning of previously changed / yanked text
    `]    Jump to the ending of previously changed / yanked text
    `<    Jump to the beginning of last visual selection
    `>    Jump to the ending of last visual selection
    `0    Jump back to the last edited file when exiting vim
    

    jump

    '       Go to the marked line
    `       Go to the marked position
    G       Go to the line
    /       Search forward
    ?       Search backward
    n       Repeat the last search, same direction
    N       Repeat the last search, opposite direction
    %       Find match
    (       Go to the last sentence
    )       Go to the next sentence
    {       Go to the last paragraph
    }       Go to the next paragraph
    L       Go to the the last line of displayed window
    M       Go to the middle line of displayed window
    H       Go to the top line of displayed window
    [[      Go to the previous section
    ]]      Go to the next section
    :s      Substitute
    :tag    Jump to tag definition
    
    :jumps   查看jump的命令
    

    相关文章

      网友评论

          本文标题:Moving In A File

          本文链接:https://www.haomeiwen.com/subject/tjlsdltx.html