Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And then there's Vim which, depending on how it was built for the respective distro, doesn't seem to accept any way to copy or paste text.

As a daily Vim user I find this to be a huge mistake in terms of user friendliness; Vim provides ways to set the clipboard as default register and other quality of life improvements, but until then a beginner has to figure out some of the weirdest keybindings to make it work, or even recompile the program because that specific distro didn't include xclip support for some reason. It is infuriating.



I understand your practical frustration, but it can be very tricky with terminal apps to reliably interact with the X display. It's basically a completely foreign interface that requires the environment to be setup properly.

But in general I just install gvim (even if I only use Vim in the terminal) since it normally means that it'll have proper X support.


Middle click paste should "just work" and be transparent to terminal apps. It's not encouraging that vim is willing and able to break this in its default settings.


I could be misremembering but I believe that middle-click paste just makes the terminal feed the contents of the X selection to stdin of the running process. I could be wrong (because there's so much arcane knowledge in terminal emulators that I won't even pretend to have scratched the surface) but I'm not sure if Vi(m) can even tell where the input comes from. Well, maybe it could by using the speed at which the characters come in I suppose, although even that might end up being unreliable over remote connections and the like.

In my humble opinion expecting good X integration for a terminal application is bound to result in frustration. I use vim in the terminal but I also never use the mouse and I configure Vim not to interact with the X selection unless I specifically instruct it to using "*. If you want better integration with the graphical environment why not just use gvim? That's what it's for.


> middle-click paste just makes the terminal feed the contents of the X selection to stdin of the running process.

Recent versions of vim hijack this by default (`set mouse=a`). This makes the middle click paste the default vim register instead of the X selection. To paste from X, you must shift+click.

Personally, I can't understand why anyone would want this, but anyway. The best part is that you can't easily disable this globally, i.e. by putting `set mouse=` in /etc/vim/vimrc. Because if a given user does not have a ~/.vimrc of their own, then defaults.vim gets loaded after /etc/vim, overriding anything set there.


> And then there's Vim which, depending on how it was built for the respective distro, doesn't seem to accept any way to copy or paste text.

I install GVim, since it tends to be compiled with the most features enabled. You can still use the vim executable in a terminal and ignore the gvim one. Then it's just "+y / "+p to copy/paste, or add this to vimrc to map it to \y, \p:

noremap <Leader>y "+y

noremap <Leader>p "+p


I didn't know about the gvim "trick", that's good to know. Generally I just set the clipboard as default register so yanks and pastes work smoothly with other programs in every situation:

    set clipboard=unnamedplus


Try Ctrl+shift+c and Ctrl+shift+v


Unfortunately that does not work either in the worst case. I'm not quite familiar with the details behind all this, but I have had cases where it was basically impossible to get any text into or out of a Vim session aside from saving it in the text file.

I believe on Alpine OS I could get it working fine by installing some dependencies and recompiling Vim manually.

Others here have suggested to install the gvim package which seems to enable proper clipboard support in every case, I will try that next time I am in that situation again.


>on Alpine OS I could get it working fine by installing some dependencies and recompiling Vim manually maybe the mantainers of the vim package didn't use sensible build flags? vim copy-pasting usually works out-of-the-box on Debian/Ubuntu and Fedora, I avoid small and cutting-edge distributions exactly because of quirks like this


This works for me on Redhat, CentOS, and OpenSuse. I pretty much limit myself to these distributions. Work and Home Respectively.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: