Introduction
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.txt
in your terminalPress
Esc
(Escape key) and Pressv
(v alphabet key) to enter VISUAL MODEUse
h
,j
,k
,l
to move cursor to select required textUse the following key binding
"*y
to 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 ,y
.
🧑💻 This is how I’ve configured my Neovim setup. You can configure it however you want. That’s the beauty of Neovim configurations.
Conclusion
I hope that this tutorial has been helpful. Feel free to checkout my products!
You just learned how to copy selected content to clipboard in Neovim. You also learned to do it using 🔥 hotkeys for better developer productivity.