From 059820630aa5bfa313ad3ca2103a88d811891457 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 18 Jan 2021 17:21:24 -0600 Subject: [PATCH] Add Allow Neovim To Copy/Paste With System Clipboard as a vim til --- README.md | 3 ++- ...vim-to-copy-paste-with-system-clipboard.md | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 vim/allow-neovim-to-copy-paste-with-system-clipboard.md diff --git a/README.md b/README.md index 1f8f6eb..289962e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1014 TILs and counting..._ +_1015 TILs and counting..._ --- @@ -1018,6 +1018,7 @@ _1014 TILs and counting..._ - [Absolute And Relative Line Numbers](vim/absolute-and-relative-line-numbers.md) - [Add A File Without Loading It](vim/add-a-file-without-loading-it.md) - [Add Custom Dictionary Words](vim/add-custom-dictionary-words.md) +- [Allow Neovim To Copy/Paste With System Clipboard](vim/allow-neovim-to-copy-paste-with-system-clipboard.md) - [Almost The End Of The Line](vim/almost-the-end-of-the-line.md) - [Alternate Files With vim-rails](vim/alternate-files-with-vim-rails.md) - [Amend Commits With Fugitive](vim/amend-commits-with-fugitive.md) diff --git a/vim/allow-neovim-to-copy-paste-with-system-clipboard.md b/vim/allow-neovim-to-copy-paste-with-system-clipboard.md new file mode 100644 index 0000000..6fcd2f5 --- /dev/null +++ b/vim/allow-neovim-to-copy-paste-with-system-clipboard.md @@ -0,0 +1,25 @@ +# Allow Neovim To Copy/Paste With System Clipboard + +By default, Neovim uses some internal registers for managing the values that +have been copied (`y`) and what should be pasted (`p`). These registers are +independent from the system clipboard, so a value copied from the browser will +not show up when you hit `p` in Neovim (or Vim). + +If you'd like to create a more seamless and cohesive copy/paste experience for +yourself, you can instruct Neovim to read from and write to the system +clipboard when copy/paste actions happen. + +This is accomplished with a `provider` that instructs Neovim to use the system +clipboard directly for all copy/paste operations. + +```vimscript +" ~/.vimrc +set clipboard+=unnamedplus +``` + +Setting the `clipboard` option to include `unnamedplus` enables that provider +"which transparently uses shell commands to communicate with the system +clipboard or any other clipboard 'backend'." So, for Mac, `pbcopy` and +`pbpaste`. + +See `:h provider-clipboard` for more details.