1

I have my fuzzy file finder in Vim and it does a pretty good job. But it always opens the file in the current tab. I want my :find to open the resulting file in a new tab.

I know I can :tabnew <file> but I need to write the complete file path here to open the file. So how do I do that?

2 Answers 2

3

The command is

:tabfind 

From :help :tabfind:

Open a new tab page and edit {file} in 'path', like with :find.

3

Ralf’s answer is the correct one, but I’ll add some more generically useful commands:

  • Prepend :vertical to any command which splits and it will use a vertical split
  • Similarly, prepend :tab to any command which splits and it will use a tab

These more general commands work for most things (so :tab help does what you thing), so they are good to have in your toolbox—especially for plugin authors, who may want to support <modifiers> in their :commands!

(Note that in this case you’d use :sfind for split, :vertical sfind à la :vsplit, and :tab sfind for tabs.)

2
  • I'm new to vim, and I'm liking it more and more. tab is like some "action" that you can add anywhere and it'll do the job right?
    – bradley101
    Jun 19, 2020 at 5:24
  • Kind of @Shantanu; it wont work for commands that dont open a split (e.g., :tab function Foo() is nonsense). But you’re on the right track! Give :help :vertical and :help :tab a read, if you haven’t already. Vim’s help rocks.
    – D. Ben Knoble
    Jun 19, 2020 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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