- update package
sudo apt-get update
- Check whether vim supports it
clipboard
, and a minus sign indicates that it does not support it
vim --version | grep clipboard
- Install with clipboard integration
vim-gtk
sudo apt-get install vim-gtk # 新版本被移除
- If an error occurs
E: 软件包 vim-gtk 没有可安装候选
sudo apt-get install vim-gtk3
- Check
clipboard
whether the installation is successful, if it is a plus sign, the installation is successful
vim --version | grep clipboard
-
configuration
vim
(optional)- Use
vim
open~/.vimrc
, add the following line (the number before the Chinese"
is a comment)
vnoremap <C-y> "+y "支持在Visual模式下,通过C-y复制到系统剪切板 nnoremap <C-p> "*p "支持在normal模式下,通过C-p粘贴系统剪切板
- Use
Or directly use the right button to copy and paste
- Instructions:
-
Copy text outside vim and paste it into the open vim file:
- Execute in normal mode
"*p
- Execute in normal mode
-
Copy data in vim to outside vim
- Execute in visua mode
"+y
- Execute in visua mode
-
reference
https://blog.csdn.net/to_free/article/details/115187981