Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Open Multiple Files at Once with FZF and Vim

open-multiple-files-at-once-with-fzf-and-vim.jpg

We'll cover how to open multiple files in a vertical or horizonal split as well as in the same buffer or a new tab.

Quick Jump:

When your FZF window is open you can select 1 or more files with Shift + TAB. By default you’ll see a little > character next to the selected files.

Then you have a few options depending on how you want to open the file and how you might have your key maps set up. For example if you’re using my dotfiles you can do:

  • Enter opens each file as a buffer
  • CTRL + v opens each file in a new vertical split
  • CTRL + b opens each file in a new horizontal split
  • CTRL + t opens each file in a new tab

Those key maps come from this part of my .vimrc:

let g:fzf_action = {
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-b': 'split',
  \ 'ctrl-v': 'vsplit'
}

Overall this can be useful if you search for something like “users” and then quickly open a controller, view and tests from the same FZF search window. I do it occasionally.

The video below demos how this works.

# Demo

Timestamps

  • 0:12 – Demoing how it works
  • 1:36 – You can open as many files as you want
  • 1:56 – Configuring things in Vim
  • 2:26 – Use cases?

Have you used this shortcut recently? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments