Command
To copy and paste from the system clipboard in Vim and Neovim, you can use the following command:
Vimscript (for Vim and Neovim with init.vim)
set clipboard=unnamedplus
Add this line to your ~/.vimrc for Vim or ~/.config/nvim/init.vim for Neovim to make it permanent:
set clipboard=unnamedplus
Lua (for Neovim with init.lua)
If you’re using Neovim with init.lua, add the following line to enable system clipboard access:
vim.opt.clipboard = "unnamedplus"
This will ensure that Vim/Neovim uses the system clipboard for all yank, delete, change, and put operations.
Usage
- Copied text from your system clipboard can be pasted in Vim or Neovim using the
porPcommands. - Text copied from Vim or Neovim using the
ycommand can be pasted in any other application usingCtrl + V(orCmd + Von macOS).