You are not logged in.
Pages: 1
Hello all,
I was wondering how I can copy things outside vim and paste it into vim. I have looked it on the internet and some people have suggested using +y/+P or *y/*P. But neither of them work. Any ideas?
Thanks!
Be nice and live for others.
https://prismatically.blog
Offline
This is how I usually do it:
1. Copy your text (e.g. select text in browser and do CTRL+C)
2. Go to vim and enter INSERT mode
3. Use the paste feature of your terminal emulator (usually CTRL+SHIFT+V or CTRL+ALT+V)
Offline
Hello and thanks for the answer. However, the terminal that I have is vim-based only. So those commands do not work
Be nice and live for others.
https://prismatically.blog
Offline
Which version of vim is installed? Afaik you need to install gvim to have relevant support compiled in (even if you just use the command line vim)
Offline
Which version of vim is installed? Afaik you need to install gvim to have relevant support compiled in (even if you just use the command line vim)
I use vim v8.1.570. Does gvim override vim or is it like another extension of vi? Also it is pretty surprising that vim does not have such a simple option.
Be nice and live for others.
https://prismatically.blog
Offline
gvim is vim (you can still call it with vim) but with X11 support compiled in, it will for all intents and purposes replace the standard vim package. vim isn't compiled with X11 support and hence has no ability to access the clipboard.
Last edited by V1del (2018-12-13 14:15:51)
Offline
Use xsel in keybindings. For example, I have this in my vimrc to use the 'insert' key to paste the content of the primary selection:
noremap <silent> <Insert> :set noautoindent<CR>:r !xsel<CR>:set autoindent<CR>
I don't really use the clipboard selection for anything, but for pasting into vim from there you could just add the -b flag to xsel in that binding.
For copying from vim to elsewhere, I rely on the terminal (st in my case) or tmux for that as I can use the mouse to select text and st puts it in the primary selection, or I can use tmux's copy mode and my tmux.conf is set up to sync the copy buffer to the primary selection. It would be pretty easy also to have vim pass the content of a visual block to a selection via xsel if you wanted that.
Vim can do any of this, but it does none of this out of the box. You need to decide what you want it to do, then put the relevant commands/bindings in your vimrc.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What is "the terminal that I have"?
Offline
Thanks for the feedback guys. Install gvim did the job. However, I faced the same issue in the vim-based terminal. And since it was a custom modified terminal, when I checked the terminal's repository, it actually had a different keybinding. All is well now.
What is "the terminal that I have"?
If you are still curios, this is the terminal.
Be nice and live for others.
https://prismatically.blog
Offline
That's not "vim based", that's a st fork with a lot of (bloated) options added including Ctrl-C and Ctrl-V copying and pasting. So just use that.
Last edited by Trilby (2018-12-13 15:58:53)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
That's not "vim based", that's a st fork with a lot of (bloated) options added including Ctrl-C and Ctrl-V copying and pasting. So just use that.
Pardon my ignorance
Be nice and live for others.
https://prismatically.blog
Offline
I take a slightly different approach...
I use the program "autocutsel" and put it in my "~/.xinitrc" file:
autocutsel -selection PRIMARY -fork
This will sync all "copy" buffers on my computers. That means I can either highlight text or Ctrl-C text and then paste it anywhere (including in Vim) with a middle mouse click.
Offline
Pages: 1