3

I've configured my VIM to find and open a file by fzf:

nmap <c-x><c-f> :Files<cr>

It works fine, but I wanna open the file in a new tab instead of the current tab with the same shortcut keys.

6
  • @filbranden When I press Ctrl-t it says about tags and Ctrl-T in my Gnome Terminal will open a new tab in Terminal generally. Do you know what's the function behind it that I set a shortcut key for it?
    – mortymacs
    Commented Dec 21, 2020 at 17:21
  • 1
    @filbranden Thanks a lot! It worked!
    – mortymacs
    Commented Dec 21, 2020 at 21:17
  • @filbranden you'll post as an answer? or I do it?
    – mortymacs
    Commented Dec 21, 2020 at 21:29
  • 1
    I'll do it. Thanks for confirming this works for you!
    – filbranden
    Commented Dec 21, 2020 at 21:38
  • 1
    Welcome to Vi and Vim!
    – D. Ben Knoble
    Commented Dec 22, 2020 at 19:19

2 Answers 2

9

The Vim fzf plug-in has a native feature to open the selected item in a new tab.

If you type Ctrl+T inside the fzf selection window, it will tell Vim to open the item in a new tab (when applicable.)

See here, below the table it says:

Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new tab, a new split, or in a new vertical split.

If this is acceptable for you, you don't need a new mapping to open files in a new tab, just to use the appropriate Ctrl+key sequence when selecting an entry, to have that entry opened in a new tab (or a split too, since that's also supported.)

0

Per the maintainer you can also configure fzf.vim to open the selected file in a new tab by default by adding this to your ~/.vimrc:

let g:fzf_action = { 'enter': 'tab split' }

The accepted solution works as well, I'm just too lazy to include those extra two key strokes.

Your Answer

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

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