In this tutorial, you’ll learn to copy selected content to clipboard in Neovim. I’ll also teach how you can configure your neovim configuration to do it using 🔥 hotkeys for better developer productivity.
I’ll be showing you how to select text in VISUAL MODE in Neovim.
💻 I’ve setup Neovim in my macOS machine but the process should be more or less similar for any linux based operation system.
Normal way of copying content to clipboard in macOS(Linux)
Open (any) text file in Neovim using,
nvim file.txtin your terminal
Esc(Escape key) and Press
v(v alphabet key) to enter VISUAL MODE
lto move cursor to select required text
Use the following key binding
"*yto yank(copy) selected text to clipboard
That’s the hard way.
Personally, I find
"*y is a long key sequence to copy text. I’ll show you how to do it faster.
Faster way of doing it (🔥 hotkeys)
This method involves a one time setup/edit (configuration) in your
~/.config/nvim/init.vim file, add the following in that file,
let mapleader="," vnoremap <leader>y "*y
Save the file and that’s it.
You can now repalce the whole
"*y sequence with
🧑💻 This is how I’ve configured my Neovim setup. You can configure it however you want. That’s the beauty of Neovim configurations.
I hope that this tutorial has been helpful.
You just learned how to copy selected content to clipboard in Neovim. You also learned to do it using 🔥 hotkeys for better developer productivity.