Searching for files in Vim.

By Darío Rivera
Posted On in Vim

When you use Vim, a recurring question is how to search for and open files directly from the console without having to exit Vim. For this, you can install the command-t plugin. We saw previously How to give Vim superpowers by installing plugins. Before we see the installation of this plugin, it is necessary to verify a couple of requirements. Let's get to work!

Plugin Installation

Like any plugin in Vim, you must add the package name and install it as you normally do. If you use the vim-plug package manager, you can add the following to your ~/.vimrc file.

Plug 'wincent/command-t'

Once this is done, you can proceed with the installation by executing :PlugInstall. But that's not all, it turns out that CommandT is still not functional, so command-t can work quickly with large amounts of files, part of the code is written in C as a Ruby extension and must be compiled to work!

Ruby Support in Vim

To be able to use command-t, you must have Ruby support in Vim. You can check this by entering vim and executing the following command:

:echo has('ruby')

If you get zero (0), you don't have support, if you get one (1) you have Ruby support in Vim. If you already have Ruby installed, you can check the version by running the following command in Vim.

:ruby puts RUBY_VERSION

If you don't have support, you'll need to install Ruby and make sure Vim loads it depending on the operating system you have.

Ruby-Vim Installation in Linux

Installing vim for ruby is usually different based on the Linux operating system you have. If you have installed GNU/Linux Debian, for example, you could provide support with the following command:

sudo apt-get install ruby vim-nox

After this, you could enter Vim and check if you already have Ruby support (you should get a 1).

Once this is done, you will need the tools to be able to compile part of the plugin. This is why you will need to have a C compiler installed on your machine. In linux you can install gcc.

sudo apt-get install gcc

You will also need the Ruby development package. If you use GNU/Linux Debian, you can run the following command.

sudo apt-get install ruby-dev

Ruby-Vim Installation in MacOS

The first step is to verify that you have Ruby installed. It is generally installed by default on MacOS.

ruby --version

If not, you will need to install it with RVM. It is not recommended to install it with brew! (You will avoid other problems during installation).

curl -L | bash -s stable
rvm install "ruby-VERSION"
rvm use VERSION


After this, you must enter the Vim folder and look for the command-t ruby file.

cd ~/.vim
find . -name "extconf.rb"

You will get the path where it is located, something similar to the following:


You must enter that folder and run that file with ruby.

cd ./plugged/command-t/ruby/command-t/ext/command-t
ruby extconf.rb

If everything has gone well, you can run the following command to generate the compilation:


You will get an output like the following:

compiling ext.c
compiling heap.c
compiling match.c
compiling matcher.c
compiling watchman.c
linking shared-object

After this, you can enter vim and use the plugin.

Using Command-t

The standard way to use command-t is through its command in Vim.


You will see that the files are listed ridiculously fast.

Acerca de Darío Rivera


Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.