how to select all and copy in vim insert mode? and is there another way to do it in normal mode?
I have tried visual mode and gg and shift + gg to select all and then yank, however that doesn't transfer it to the clipboard to be able to paste it in another application like skype or chrome browser.
I am sure this is a common task, and there are a lot of varieties by smarter ppl than me out there, please feel free to share yours.
If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor.
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.
Use $yy To Select and Copy All There is an alternative way that can be used to select and copy all content. The yy command is used to yank or copy the current line but providing the line count we can select and copy all lines. First change to normal mode with the ESC.
In normal mode:
gg"+yG
In ex mode:
:%y+
There are a few important informations missing from your question:
$ vim --version
?If your Vim was built with clipboard support, you are supposed to use the clipboard register like this, in normal mode:
gg"+yG
If your Vim doesn't have clipboard support, you can manage to copy text from Vim to your OS clipboard via other programs. This pretty much depends on your OS but you didn't say what it is so we can't really help.
However, if your Vim is crippled, the best thing to do is to install a proper build with clipboard support but I can't tell you how either because I don't know what OS you use.
edit
On debian based systems, the following command will install a proper Vim with clipboard, ruby, python… support.
$ sudo apt-get install vim-gnome
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