VIM Basic

作者: AwesomeAshe | 来源:发表于2016-03-06 19:35 被阅读162次

    模式转换##

    常用的两种模式就是普通模式和插入模式
    Normal Mode进入Insertion Mode

    a //=append
    i //=insert
    
    esc //go back to Normal Mode
    

    delete

    d   //delete selected
    dd  //delete the whole line
        //or CUT actually, you can "p" paste it
    
    n dd //delete n lines (down)
    
    dj  //j directs downwards , so delete current line and the one later
    
    D   //delete from cursor to END of line
    
    d^  //delete till bengining of line
    
    dG   //delete to END OF FILE
    
    d1G  //to beginning of file
    
    
    dw   //delete a word删除一个单词
    dnw  //delete n words
    
    x  //delete a letter
    nx //delete n letters
    
    

    普通模式下的命令##

    .   //repeate last operation重复上一次操作
    
    gg  //to begining of file
    G   //to end line of line
    
    set nu  //显示行号
    n G     //goto nth line跳转到第n行
    
    ctrl o  //回到上一次的游标地址
    
    ## copy&paste ##
    
    y   //copy what's been selected
    
    yy  //copy the whole line
    
    yw  //copy a word
    
    ynw  //copy n words
    
    y^/y0   //copy to begining of line
    y$      //copy to end
    
    p   //粘贴到光标这一行之后
    P   //粘贴到光标这一行之前
    
    ## replace ##
    
    r<..>   //replace cursor with input
    R <..>  //esc to stop
    cc      //delete whole line & replace
    cw      //replace a word
    
    ~   //反转大小写capslock
    
    u   //undo once
    un  //undo n times
    U   //undo all operations on current line
    ctrl+r  //redo what you undo
    
    ## 缩进&排版 ##
    
    <<  //shift what've been selected left
    >>  //shift selected right
    
    ce  //居中center
    le  //left
    ri  //right
    
    ## find ##
    
    /<word> //向下查找word
    ?<word> //向上查找
    
    n   //next, 继续原来方向查找下一个
    N   //反方向查找下一个
    
    

    VISUAL MODE##

    v       //进入选择模式,每次选择一个字符
    shift V //select a whole line
    ctrl v  //select a block
    
    //the same to end select
    
    
    

    多文件编辑

    vim 1.txt 2.txt //create&open several files
    
    n               //edit next file
    N               //edit former file
    
    e filename      //open new file
    
    e#              //back to last file
    
    ls              //list edited files
    
    f                   //show file name
    f newname filename  //rename
    

    set instructions

    set nu  //显示行号
    
    

    相关文章

      网友评论

        本文标题:VIM Basic

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