Cut to the system clipboard from Vim on Ubuntu

后端 未结 8 1495
灰色年华
灰色年华 2020-12-02 13:34

I am using Ubuntu 12.04 Beta and Vim that has come with it. I am trying to use Vim to copy the content of a text file to Chrome browser. I have tried +, *

相关标签:
8条回答
  • 2020-12-02 13:53

    You can do it; just pipe to xclip.

    gg
    V
    G
    :'<,'>w !xclip
    

    from here: in vim with xclip, yank to clipboard

    0 讨论(0)
  • 2020-12-02 13:53

    I would open the file in the browser using a file URL:

    file:///home/dave/some-file
    

    Not super elegant but it works.

    0 讨论(0)
  • 2020-12-02 13:59

    If you have run configure as explained by @DrAl but you still can't get the GUI compiled in and you see this in the output of your ./configure

    checking for X... (cached) no
    

    Then you may have to delete the cache file that configure created.

    find . -name config.cache -delete
    

    Then re-run configure and make and check src/vim --version again - it should show that gui is included now.

    0 讨论(0)
  • 2020-12-02 13:59

    I really enjoy this set of shortcuts:

    " Add shortcut for clipboard registers
    noremap <leader>p "*p
    noremap <leader>y "+y
    noremap <leader>d "+d
    

    It is just an easier way then type "* and "+ every time.

    0 讨论(0)
  • 2020-12-02 14:01

    You can also add shortcuts to your vimrc

    # Copy and paste
    vmap <C-c> "+yi
    vmap <C-x> "+c
    vmap <C-v> c<ESC>"+p
    imap <C-v> <ESC>"+pa
    

    It will allow you to Copy by Ctrl + C and Paste by Ctrl + V

    0 讨论(0)
  • 2020-12-02 14:12

    Install the package vim-gnome instead of vim. It comes with clipboard enabled.

    0 讨论(0)
提交回复
热议问题