Is it possible to copy to clipboard directly from vim? e.g I want to be able to use all the functionality that a normal vim command allows, like lets say if cc means copy line to clipboard, then 4cc should copy 4 lines etc. Is there any such command in vim or you can only yank stuff within vim?
Use the register "+ to copy to the system clipboard (i.e. "+y instead of y).
Likewise you can paste from "+ to get text from the system clipboard (i.e. "+p instead of p).
The * register will do this. In Windows, + and * are equivalent. In unix there is a subtle difference between + and *:
Under Windows, the * and + registers are equivalent. For X11 systems, though, they differ. For X11 systems, * is the selection, and + is the cut buffer (like clipboard). http://vim.wikia.com/wiki/Accessing_the_system_clipboard
* is probably what you want most of the time, so I use * because it functions as I expect it to in both environments.
If you are using GVim, you can also set guioptions+=a. This will trigger automatic copy to clipboard of text that you highlight in visual mode.
Drawback: Note that advanced clipboard managers (with history) will in this case get all your selection history…