启用右键粘贴

方法一

1
:set mouse-=a

方法二

编辑 ~/.vimrc 文件,加入如下代码:

1
2
3
if has('mouse') 
set mouse-=a
endif

补充:

vi的三种模式:命令模式插入模式可视模式。鼠标可以启动于各种模式中:

1
2
3
4
5
6
7
8
The mouse can be enabled for different modes:
n Normal mode(普通模式)
v Visual mode(可视模式)
i Insert mode(插入模式)
c Command-line mode(命令行模式)
h all previous modes when editing a help file(当编辑一个帮助文件时,开启所有模式)
a all previous modes(所有模式)
r for |hit-enter| and |more-prompt| prompt(提示输入|更多提示|提示 模式)

显示行号

1
:set num

切换至某行

1
:n #n为行号

设置为系统默认编辑器

修改环境变量EDITOR

1
2
3
4
5
6
# 临时
export EDITOR=vim
# 登录时生效(~/.bashrc或~/.profile)
echo "export EDITOR=vim" >> ~/.bashrc
# 配置到全局(/etc/bashrc或/etc/profile)
echo "export EDITOR=vim" >> /etc/profile

快速复制/粘贴一行

复制

yy

复制多行

nyy,如3yy,复制三行

粘贴

p

删除行

删除一行

dd

删除多行

ndd

删除包括所在行前面的全部

dG

删除包括所在行后面的全部

dgg

撤销一次操作

u

还原一次操作

Ctrl+r