上善若水,不进则退

姚毛毛

左手代码,右手写诗

linuxido.com

vim全选复制

网上一堆答案全是ggyG,根本不行,
正确答案应该是

gg"*yG

或者

gg"*+yG

下面是在stack overflow 上找到的答案,亲测有效,在此记录下
stackoverflow原文,点这个链接,或看下面内容:

You should yank the text to the * or + registers:

gg"*yG

Explanation:

    gg to get the cursor to the first character of the file
    "*y to start a yank command to the register * from the first line, until...
    G to go the end of the file

为什么可以

  • gg 移动到首行
  • "* 表示使用当前选择区
  • y 复制选中内容到0号寄存器
  • "+y 把选中内容拷贝到"+号剪贴板,即系统剪贴板
  • G 移动到尾端

如此解读就是先移动到首行然后选中当前行然后复制,并保持这个姿势一直到文件内容尾端

当然,这是我个人的猜想,对于vim的使用还不熟悉,如有谬误就贻笑大方了

posted @ 2018-04-19 10:14  姚毛毛  阅读(415)  评论(0编辑  收藏  举报