Copy all the lines to clipboard

前端 未结 25 2362
礼貌的吻别
礼貌的吻别 2020-11-28 16:54

Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it\'s not using clipboard to store those lines.

So

25条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 17:23

    I have created a function to perform this action, place it on your ~/.vimrc.

    fun! CopyBufferToClipboard()
        %y+
    endfun
    nnoremap y :call CopyBufferToClipboard()
    command! -nargs=0 CopyFile :call CopyBufferToClipboard()
    

    OBS: If you are using neovim you also need some clipboard manager like xclip. for more information type in neovim :h checkhealth

    It is also important to mention that not always a simple y will copy to the clipboard, in order to make every copy feed + wich is "Clipboard Register" try to set: :set clipboard=unnamed,unnamedplus. For mor information see: :h unnamed.

    Here more information on vim wikia.

提交回复
热议问题