112

I'm trying to get command-t installed for vim but my current version of vim doesn't have the (+ruby) flag. The command "which ruby" shows that ruby is installed.

What do I need to do in order to activate the +ruby flag in vim?

Also, what does the +ruby flag technically mean?

Chris Greer
  • 1,121
  • 2
  • 8
  • 3
  • What OS? You cannot get +ruby without reinstalling vim. – ZyX Sep 25 '10 at 18:10
  • Linux (ROCKS). I re-installed it after I checked for ruby, How do I enable the flag during compiling? Do I need to edit something in the ./configure make make install process? – Chris Greer Sep 25 '10 at 18:31

13 Answers13

98

Some package provides vim-ruby on Ubuntu, for example vim-nox.

simply:

sudo apt-get install vim-nox;

will get you vim with ruby, as well as compiled in "support for scripting with Perl, Python, Ruby, and TCL but no GUI."

sudo apt-get install vim-rails

will install a "selection of vimscripts that make editing Ruby on Rails applications extremely easy." but as it depends on vim-full and vim-addon-manager, it will also install the vim-gnome version of the GUI, that is "a version of vim compiled with a GNOME2 GUI and support for scripting with Perl, Python, Ruby, and TCL."

Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
DenMark
  • 1,618
  • 1
  • 15
  • 16
  • yes, I think often people end up with the "vim-tiny" Debian package, which doesn't have ruby support. Remove vim-tiny and install vim-nox – Eric Drechsel Dec 22 '11 at 10:34
  • One thing to keep in mind is that pulling in Ruby support from the APT package handling utility is that Apt will want to pull in ruby1.8 as well. Not an issue for me, since my "development Ruby" is on virtual machines, so I don't care what version of "system Ruby" I have, as long as it does not break anything. I installed "vim-rails," which pulled in everything I seem to need--vim was compliled with +ruby, but linked with -lruby1.8 I'm not sure, however, what "vim-nox" provides, except maybe a darker and scarier editor. Perhaps @DenMark could edit his answer to provide that info. – Dmitri Jan 22 '12 at 20:11
  • This didn't work for me on Ubuntu 18.04. See https://askubuntu.com/a/1092140/2273 – Adam Monsen Nov 12 '18 at 07:42
  • Re: @Adam Monsen's comment, this *did* work for me on ubuntu 18.04 – Matt Parrilla Jan 31 '19 at 16:47
  • Ah, thanks @matt-parrilla. Mine still may be useful for folks wanting GUI integration, for example, copy/paste with the xorg clipboard. If not I'll just delete my comment above. – Adam Monsen Feb 02 '19 at 01:30
43

I think "Compiling Vim With Ruby Integration On Snow Leopard" might actually help. I'm on exactly same boat at the moment.


Ok... got it to work. Took me like half hour or so.

This should help (I got Ubuntu):

sudo apt-get install mercurial
hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-rubyinterp
make
sudo make install

To test if things look fancy:

vim --version | grep ruby

Should return something like:

-python3 +quickfix +reltime -rightleft +ruby +scrollbind +signs +smartindent

Ruby should have plus now. Another trick to test it - enter vim and hit :ruby 1. Should not fail.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
  • I have tried this on Cent_OS but with no success. Tried "./configure --enable-pythoninterp --enable-rubyinterp --enable-cscope --with-features=HUGE --prefix=/home/devel" but vim --version tells me both -python -python3 -ruby. What's wrong? – Martin Macak Feb 10 '13 at 10:21
  • @MartinMacak you could try reading output of configure. it should give some kind of clues. but it's quite tricky. having hard time to get python enabled myself. – Arnis Lapsa Feb 10 '13 at 14:38
  • 3
    You should also install ruby-dev under Ubuntu, otherwise you'll see configure complain: checking for ruby... /usr/bin/ruby checking Ruby version... OK checking Ruby rbconfig... RbConfig checking Ruby header files... not found; disabling Ruby – fvdnabee May 18 '13 at 11:12
  • @logion, thanks for your comment, which would better be another answer. – Enlico Jul 03 '20 at 20:36
23

On mac os x, assuming you have Homebrew installed:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/vim.rb

This version of vim has ruby support enabled

Source: http://blog.jerodsanto.net/2011/08/brew-install-vim/

EDIT: edited the url, thanks @david-xia for mentioning the change

UPDATE: Apparently, homebrew vim now comes with ruby support enabled by default so you just need to do brew install vim (see comment below)

Pierre
  • 1,252
  • 1
  • 14
  • 24
  • 2
    The source has moved. Use `brew install https://raw.github.com/Homebrew/homebrew-dupes/master/vim.rb` – David Xia Mar 27 '12 at 01:43
  • 2
    The `vim` formula no longer exists in this repo and [has been moved to `core`](https://github.com/Homebrew/homebrew-dupes/commit/70c575e7ffa608c76b8580d86d263073532ca6b9). You can just do `brew install vim` now. – Aamir Dec 20 '12 at 13:32
  • Thanks for the info, I've updated the answer to reflect that. – Pierre Feb 11 '13 at 17:38
14

If there isn't a Ruby enabled Vim available for your operating system, you'll have to recompile. This is very easy and there are some instructions on the Vim website I believe. If you're on Linux, you use configure to choose what you want. Have a look at the output of:

./configure --help

in the Vim source directory. Read it carefully, there are a lot of options in there. The main one you want is --enable-rubyinterp, but you may also want to add --with-features=HUGE among others. As I said, read the help provided.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
DrAl
  • 70,428
  • 10
  • 106
  • 108
11

when you run ./configure you need to add the folowing --enable-rubyinterp

./configure --enable-rubyinterp
skeept
  • 12,077
  • 7
  • 41
  • 52
6

On Mac OS X, I find that the easiest is to install MacVim with brew install macvim which includes +ruby. And then symlink /usr/local/bin/vim to /usr/local/bin/mvim. That way to get a recent Vim version, with the huge feature set, +ruby, both GUI and command line vim just using the standard HomeBrew repository. No need for external repository like in Pierre answer

To avoid issues it's better to use the use the system ruby during installation so:

rvm use system
brew install macvim
ln -s /usr/local/bin/mvim /usr/local/bin/vim
RubenLaguna
  • 21,435
  • 13
  • 113
  • 151
5

Flag +ruby means that vim is compiled with ruby support and linked against ruby interpreter library. You cannot get this flag without recompiling vim or installing another version which is compiled with this flag.

ZyX
  • 52,536
  • 7
  • 114
  • 135
3

Pulling the vim source using Mercurial and changing into the directory will give you the ability to configure your vim install before you compile it.

hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-rubyinterp

The --enable-xxinterp option can be used for Python, Perl, or any other language that Vim will support. Just type it in where the xx is and it will work.

Running the help option with the configure command will allow you to see all of the configuration options.

./configure --help
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
amargherio
  • 148
  • 1
  • 7
2

Under Windows you can install Vim from here:

http://sourceforge.net/projects/cream/files/Vim/

Version 7.3.3 seems to be compiled with Ruby support (see release notes file). The newest 7.3.x currently is not.

Matt
  • 5,328
  • 2
  • 30
  • 43
1

If you are using MacPorts in OSX, you may try

sudo port install vim +ruby

To specify a different ruby version, you may try

sudo port install vim +ruby18

or

sudo port install vim +ruby19
Chuan Ma
  • 9,754
  • 2
  • 45
  • 37
1

It looks like you need to have ruby installed before install vim-nox.

This works for me on Ubuntu 18.10

sudo apt-get install ruby rubygems vim-nox

Source: https://junegunn.kr/2013/09/installing-vim-with-ruby-support

Shuo Feng
  • 445
  • 7
  • 13
1

Installing vim-rails will add Ruby (+ruby) support. I just tried and verified that it works and Command-T runs fine now.

sudo apt-get install vim-rails

Mike Crittenden
  • 5,779
  • 6
  • 47
  • 74
0

If you are lazzy and don't want to recompile you can try to find a package with a vim version including ruby. On debian it's vim-ruby so something like

apt-get install vim-ruby 

might work. (I can't try it, I m on mac. On mac , MacVim come with ruby enabled)

mb14
  • 22,276
  • 7
  • 60
  • 102