Say, I have the following mapping:
map <F4> :execute "vimgrep /" .expand("<cword>") . "/j **" <Bar> cw<CR>
which (recursively) greps the current directory for instances of the word under the cursor and opens these files in the quickfix list window.
From the quickfix window, how do I launch the file that I open into a new tab? Enter just changes my current buffer in the window to that new file.
Quickfix-window commands respect the switchbuf
option when creating the buffer. The switchbuf
option has the newtab
specifier that instructs Vim to open a new tab page before loading the buffer to switch to. If one adds this key to the option via
:set switchbuf+=newtab
the entries in the quickfix window will be opened in separate tab pages.
There is the usetab
specifier that also might be useful in this case. It prescribes Vim to switch to an existing tab page if it contains a window displaying the target buffer, instead of duplicating it in a new tab.
:set switchbuf+=usetab,newtab
The value of switchbuf
also (partially) affects other buffer-switching commands, such as :bfirst
, :blast
, :sbuffer
, :sbnext
, and :sbprevious
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With