VIM下的插入模式的相关知识:

1. 建议:当打错一个单词时,删除掉重新打一遍, 避免在错誤的基础上进行修改;

2. 在插入模式下,可以用一些组合键,它也可以用于VIM 命令模式下,也可以用于 base shell 下;

ctrl-h          删除前一个字符;
ctrl-w          删除前一个单词;
ctrl-u          删除至行首;

从插入模式返回到普通模式

有三个方法,其中ECS 与 ctrl+[ 是相同的;而ctrl-o 会临时进行普通模式,执行完一个普通模式下的命令以后会立刻返回到插入模式;

Esc        返回普通模式;
ctrl+[        返回普通模式;
ctrl+o        返回插入-普通模式;

ctrl-o, 我觉得很方便的;

在插入模式下,粘贴寄存口中的文本

在插入模式下,输入ctrl-r{register}就可以加入寄存中的内容;

可以输入:h i_ctrl-r 命令进行看看特殊的寄存器的名字含义;

Special registers:
                        '"'     the unnamed register, containing the text of
                                the last delete or yank
                        '%'     the current file name
                        '#'     the alternate file name
                        '*'     the clipboard contents (X11: primary selection)
                        '+'     the clipboard contents
                        '/'     the last search pattern
                        ':'     the last command-line
                        '.'     the last inserted text
                        '-'     the last small (less than a line) delete        
                                                        *i_CTRL-R_=*
                        '='     the expression register: you are prompted to
                                enter an expression (see |expression|)
                                Note that 0x80 (128 decimal) is used for
                                special keys.

如:在插入模式下,输入ctrl-r,它会出来“, 然后再输入0, 就可以插入最后一次复制的内容了;

在插入模式下利用表达式寄存器作计算

在插入模式下,按 ctrl+r ,然后再按= 就可以进行表达式寄存器,在这时就可以输入加减乘除,最后的结果输入的文本当中;

用字符编码插入非常字符

当一些特殊的字符在键盘中不容易输入时,这时可以通过输入相应字符的编码来输入它们;

方法为: ctrl + v {code}

VIm中的编码共3位数字,如A的编码为65,这时,就可以输入: ctrl+v,再输入065就可以;

不过对于使用unicode编码的字符,用的为4位16进行进行编码的,此时的输入为:ctrl+v,再输入u, 然后再输入编码;

如:¿ 为00bf, 此时,输入 ctrl-v, u, 00bf。

使用 ga 命令可以把光标上字符的编码显示出来;

使用:h i_ctrl-v_digit 看更多详细内容;

参考:VIM实用技巧,第二版,作者:Drew Neil;翻译:杨源, 车文隆;

原文地址:https://www.cnblogs.com/yinheyi/p/6945859.html