I tried to copy text from IDEA with ideavim plugin, using default vim keybindings (y). But this text isn't copied in global buffer and i can paste it only in IDEA.
How can I use copied piece of text in browser, for example?
Vim's yank command doesn't yank to the system clipboard by default; it yanks to the unnamed register. You can use the * or + register to access the system clipboard; also see this wiki article for more information. Or just set this option in your ~/.ideavimrc
:
set clipboard+=unnamed
This ~/.ideavimrc
setting has been supported in IdeaVim since VIM-476 was implemented in version 0.38. If the file does not exist create it in your user/home directory.
Note also that this is all standard Vim behavior; none of it is specific to IdeaVim except for the name of the config file.
set clipboard+=unnamed
uses the *
register, aka primary selection. If you prefer to use register +
, aka clipboard, then ``set clipboard+=unnamedplus. You can also set these interactively from the
:` prompt to experiment and see what works best for you. –
Novelty "+y
with a selection in visual mode. –
Aleurone Another option is that you can go to the setting of the ideavim plugin and set ctrl + c
and ctrl + v
to be handled by the IDE and not by vim.
This will allow you to copy and paste as usual in the IDE and paste outside the IDE as well.
Note
when you set ctrl + v
to be handled by the IDE ctrl + v
for selection will not work in VIM. As an alternative you might just use ctrl + shift + v
in IDE as default (works by default for paste with selection)
Steps
in your lower right corner select settings:
Then search for the shortcut and select the option IDE
for handler.
The accepted answer will also copy deleted content to the system clipboard (using d
, dd
, ...), basically turning deletion into a "cut to clipboard" operation. If (like me), that's not what you want at all, you can add the following mappings to ~/.ideavimrc
:
# Use system clipboard by default for y and p operations
nnoremap yy "+yy
vnoremap y "+y
nnoremap p "+p
vnoremap p "+p
nnoremap P "+P
vnoremap P "+P
# Allow access to original y and p operations with leader key, e.g. to use registers
nnoremap <leader>yy yy
vnoremap <leader>y y
nnoremap <leader>p p
vnoremap <leader>p p
nnoremap <leader>P P
vnoremap <leader>P P
# Allow to cut to system clipboard by using leader key with d
nnoremap <leader>dd "+dd
vnoremap <leader>d "+d
(courtesy of https://gist.github.com/RobertAudi/11ffa90f4952e5923ce7 and @albert-bici)
"a yy
anymore - which is rater annoying... –
Ferity "_
. For example maybe nnoremap d "_d
and vnoremap d "_d
would give you deletion to black-hole, so you can leave y
and p
mappings alone. –
Surd nnoremap zy "*y
nnoremap zY "*Y
vnoremap zy "*y
vnoremap zY "*Y
. Or instead of zy
use <leader>y
. –
Surd I just discoverd that IdeaVim now has this setting "built-in." In the .ideavimrc file, put in set clipboard^=ideaput
. Save and restart the IDE and it should now use the system clipboard.
I found that unnamedplus
has the best behaviour on Linux & Mac OS. It allows me to select words with IntelliJ, and yank, and paste over them, while still allowing system clipboard usage.
In your ~/.ideavimrc
file, add:
set clipboard+=unnamedplus
© 2022 - 2025 — McMap. All rights reserved.