VIM shares the clipboard with the system

  • 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

grep

  • Install with clipboard integrationvim-gtk
sudo apt-get install vim-gtk	# 新版本被移除
  • If an error occursE: 软件包 vim-gtk 没有可安装候选
sudo apt-get install vim-gtk3
  • Check clipboardwhether the installation is successful, if it is a plus sign, the installation is successful
vim --version | grep clipboard

clipboard

  • configuration vim(optional)

    • Use vimopen ~/.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粘贴系统剪切板
    

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
    • Copy data in vim to outside vim

      • Execute in visua mode"+y

reference

https://blog.csdn.net/to_free/article/details/115187981

Guess you like

Origin blog.csdn.net/qq_43377653/article/details/130169328