1

I'm able to search open a file in the current tab, but not able to open in a new tab.

I was watching this tutorial, but I'm unable to open a file in tabs or splits. When I try ctrl-t I get this error enter image description here

1
1

If you check help file for the quickfix you will find that it has <CR> to open in existing window and <C-w><CR> to open in a split window. There is also a mapping to move a split to a new tab <C-w>T -- so we have some pieces to work with.

Simple mapping :nnoremap <C-t> <C-w><CR><C-w>T does the job.

Pressing <C-t> would:

  1. create new split window (<C-w><CR>)
  2. move this split window to a new tab (<C-w>T)

But this <C-t> is now available everywhere which doesn't make sense -- you should create this mapping only for a quickfix window:

augroup quickfix_tab | au!
    au filetype qf nnoremap <buffer> <C-t> <C-w><CR><C-w>T
augroup END

enter image description here

4
  • I should have mentioned I'm new to vim 😅. I just want <C-t> to open the highlighted line in new tab. But that is not happening for me. Oct 25 '20 at 11:23
  • 1
    @NikhilWagh this answer is about it.
    – Maxim Kim
    Oct 25 '20 at 11:28
  • I copied your augroup into my vimrc and it worked thanks. Oct 25 '20 at 11:38
  • An ftplugin would work as well.
    – D. Ben Knoble
    Oct 25 '20 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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