Vim Selection Problems with VirtualBox Appliance

I was happy to see there was a pre-made VirtualBox demo appliance for NixOS!

My display resized correctly, and it was trivial for me to nixos-rebuild to get vim installed. Bidirectional clipboard appeared to work at first. But while I could select with the mouse and Copy in Konsole while running a shell, I found that while vim was running the option was grayed out:

plain-vim-select

Reading up a bit, I thought it may be because the plain vim package was not built with libX11 or libXt dependencies, and didn’t know anything about the clipboard. One can observe that :echo has('clipboard') comes back in zero.

So I tried instead swapping the vim package for vim_configurable, which changed that response to one. But that didn’t seem to help, Copy was still disabled:

vim-configurable-select

HOWEVER I found that the Copy button became enabled by holding the SHIFT key while selecting. This worked in both vim and vim_configurable, and actually creates a secondary kind of selection to which the Copy button exclusively applies:

shift-vim-select

Flailing around a bit, I found the suggestion of telling vim to :set mouse=r (instead of mouse=a) gets the second selection behavior without a shift.

I wanted to put that in a .vimrc file, but apparently in Nix you can’t use a ~/.vimrc file to persist this change without losing the rest of the configuration. Instead you’re supposed to use vim_configurable and somewhere say something to the effect of:

vim_configurable.customize {
   name = "vim-with-plugins";
   vimrcConfig.customRC = ''
      set mouse=r 
   '';
 }

But I am too much of a noob to know where to put this in the demo virtual appliance configuration.nix. Depending on where I put it, I get warnings that vim_configurable is an unknown variable or doesn’t evaluate to a package, or I can get it to rebuild but just not have an effect.

ChatGPT couldn’t help on this so I thought I’d sign up for the forum and ask real people. :slight_smile: