Yank a whole file in Vim
Vim is an incredible tool. Sometimes, it allows us to do the same things in a very different ways. Recently, I’ve found a shorter way to yank (in other words to copy) a whole file.
This way is using the Ex (colon) command: %y
.
There is a "classic" way of yanking a whole file. This is a sequence of commands: ggyG
. But there is a caveat in this approach. What if you need to copy it to the system clipboard? It becomes: ggVGy+
. Seems a little cumbersome, doesn’t it?
With the Ex command, you can do the same with just: %y+
.
Note: works in IdeaVim too.