DEV Community

Cover image for Vim tips: Speed up with Vim tabs
CHADDA Chakib
CHADDA Chakib

Posted on

Vim tips: Speed up with Vim tabs

I struggled a long time ago with vim when playing with multiple projects at the same time or playing with a code base with conflicting folders related to multiple languages used at the same time.

As an example, a typical rails code base will have a lot of ruby code and a bunch of javascript/typescript code ( stimulus, react ... ).

As an example, we can have a ruby service for invoicing for example
.../services/fetch_invoice_service.rb

and a typescript service used to fetch something from the API
.../javascript/src/services/fetchDataService.ts

On vim, using fzf I found my self using the Gfilescommande to find the desired file typing for example:
servicefetch

The Fzf will show ruby and javascript files on the same list.
Sometimes is really annoying when you're working on a big codebase.

Also, when you are working on multiple project on the same time with vim, usually you find your self having multiple vim instances.

We can fix this with Vim tabs

Vim tab to rescue

You can create a new tab on vim using the command: :tabnew

Navigation between tabs is done by:

  • gt cycling between tabs
  • {tab number}gt: switch to a specific tab.

Setting a working directory by tab:

To make your search for files really fast, you can set a working directory by tab.
:tcd [path to your folder]

Calling :Gfiles will use this path as a root directory

Rails workflow

I found my self for a rails app using three tabs:

  1. The root tab on my project
    Alt Text

  2. The javascript tab within app/javascript
    Alt Text

  3. The terminals tabs
    Alt Text

Top comments (0)