I am trying to copy a selection of text from vim to another windows application...say firefox or notepad for example. However I can't seem to do this with the y
command. I have windows hotkeys enabled so by pressing ctrl-c
I can achieve this but was hoping to get rid entirely of these windows commands in Vim.
Is this possible? also what about vice versa copying from windows and pasting into vim
In vim command mode press v , this will switch you to VISUAL mode. Move the cursor around to select the text or lines you need to copy. Press y , this will copy the selected text to clipboard. Go to any external application and CMD + v to paste.
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
Another easy way to copy the entire file if you're having problems using VI, is just by typing "cat filename". It will echo the file to screen and then you can just scroll up and down and copy/paste.
You can use :set mouse& in the vim command line to enable copy/paste of text selected using the mouse. You can then simply use the middle mouse button or shift insert to paste it.
I have
set clipboard=unnamed
in my ~/.vimrc. Then "yy", "D", etc, yank directly to the Windows clipboard. It also works in MacVim. For Linux gvim, you have to remember to prefix these operations with "+
I don't see any harm in using Windows command keys in GVim. Alternatively, you can also use the hotkey "+y
for yanking (copying) and "+p
for pasting to and from the system clipboard. This works on most platforms (Vim instances that are not directly attached to an X server on unix are a bit more difficult).
as per above answers:
"*y
"*p
Using ctrl-v will make entering control characters tough in insert mode, and ctrl-v is visual-block in normal mode, although so is ctrl-q.
Personally have found the following quite natural & little finger friendly
vmap <a-c> "*y
imap <a-p> "*p
Don't use windows bindings as you then won't be able to be as good in Vim on other platforms.
Use "*y
- copy to system clipboard. It works well on Mac Os, Windows, Linux.
If you want to copy from a window (or from vim), try :
:set paste
But be careful other options may be modified. Everything is detailed in :
:help paste
Hope it helps.
For Windows 7, you need to edit the vim config file at:
C:\users\<User>\vimfiles\vimrc
just add the following line to the config file:
set clipboard=unnamed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With