2

My distribution comes with a minimal version of Vim. vim --version returns -clipboard, so the * and + registers interact (copy/paste) with the primary and clipboard do not work.

The resources I've found suggest installing Gvim to solve that, e.g. vim-athena or vim-gtk3 packages in Debian, but I will never use it.

Can I get Vim with clipboard but with no GUI?

3 Answers 3

3

Building Vim from the source with the right flags is the general solution.

git clone https://github.com/vim/vim.git
cd vim/src
./configure --with-x=yes --disable-gui

The last command will probably raise an error message, which means you need to install dependencies. Experienced users know how to proceed, but if it's your first time on this, bad news is there isn't a magic solution, you need to track down the dependencies with your package manager or a search engine and keep trying the last line. In Debian and Ubuntu,

apt build-dep vim

will solve a great deal of those.

Once ./configure succeeds,

make -j9

and if all the dependencies were satisfied, you can finally install it, but first uninstall your current Vim package, if any. As root,

apt remove vim  #for Debian/Ubuntu
make install

See also: Installing Vim help page.

3

If you don't mind having gvim installed you can run gvim in commandline mode with gvim -v. Then you should have a version of commandline vim able to access the keyboard.

Also if gvim is invoked as vim it will act like it was invoked as gvim -v, so if you do something like this:

mkdir -p ~/bin
ln -s /usr/bin/gvim ~/bin/vim
echo "PATH=~/bin:$PATH' >> ~/.bashrc

That will create a symlink to gvim under the name of vim and put it in the path before anything else. That way when vim is launched it will run gvim in commandline mode, which should clipboard support without a GUI

Finally if you have root access and this is an debian/ubuntu system you can run:

sudo update-alternatives --config vim

And then select vim.gtk3 or vim.athena

2
  • 2
    This is all correct and useful, though I would be surprised if installing gvim didn’t also install a vim link to it.
    – D. Ben Knoble
    Dec 28, 2021 at 22:54
  • 1
    @D.BenKnoble In Gentoo, installing gvim does not install a vim link to it.
    – Quasímodo
    Feb 8 at 19:51
0

I have the same need: have vim without gui (gvim)
I used before vim-gnome under ubuntu 18.04 (Bionic).
Recently, I switch to ubuntu 22.04 (Jammy) and vim-gnome package are no more available and it seems only vim with GUI like vim-gtk3 has clipboard option management.

I switched to neovim which have clipboard option (to manage with operating system clipboard), and basically have no GUI.

9
  • 1
    Neovim does not have a clipboard. It fully relies on a presence of external utilities such as xlip, xsel etc.
    – Matt
    Jun 9 at 13:31
  • @Matt I used vim-gnome because it have clipboard option and I can, for example, run "+yy to copy a line in OS clipboard, and "+p to paste from OS clipboard. I would like to have the same option in vim under ubuntu Jammy (22.04) and after apt install vim the version hasn’t got it. With neovim, I have it. Ok, I edit and add option
    – bcag2
    Jun 10 at 8:58
  • What they package in Ubuntu stays in Ubuntu. It's not about Vim/Neovim per se. Yet AFAIK the package name in Debian (and Ubuntu as well) is vim-gtk3.
    – Matt
    Jun 10 at 9:18
  • 1
    Welcome to Vi and Vim! This answer has been flagged as "Not an answer." It is hard for me to follow how this answers the original question: are you suggesting that Neovim has clipboard support even without a GUI like GVim? If so, an edit to clarify would help. Or perhaps you actually have a question about the Vim packages on Ubuntu (based on some comments)? In this case, please use the "Ask Question" button instead.
    – D. Ben Knoble
    Jun 10 at 14:07
  • @D.BenKnoble, thank for your welcome. vim-gtk3 has GUI, so for me it is not a right answer. As many people I think, I prefer install a package than build from sources, so second answer didn’t convinced me too. Of course, neovim is not vim but it is vim-based and seems keep very close used to vim, so I don’t understand why you tag my answer as "Not an answer".
    – bcag2
    Jun 13 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.