Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to work with quickfix without ever having a split window.

So I've set:

set switchbuf=newtab

as mentioned at http://stackoverflow.com/questions/6852763/vim-quickfix-list-launch-files-in-new-tab

Now:

tab copen

opens the quickfix window on a new tab.

But if I hit enter on a quickfix item, instead of creating a new tab, it first opens the location on a split in the current tab.

Only after this first split do new tabs get opened.

Is it possible to get new tabs from the first <enter>, and never see any splits?

Tested on Vim 7.4.

share|improve this question
    
The <enter> cannot hold it is too late꙰ⷭⷵ – leftaroundabout Mar 23 at 19:06
    
@leftaroundabout I don't understand :-) – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Mar 23 at 21:36
    
@leftaroundabout reminds me of that famous Stack Overflow post about parsing HTML with regex … which itself derives from something else, not sure what. – muru Mar 24 at 6:42
1  
@muru: it's originally from a famous poem. – leftaroundabout Mar 24 at 10:47
up vote 4 down vote accepted

This workaround seems to work (mind the capitalized T in the end):

autocmd FileType qf nnoremap <buffer> <Enter> <C-W><Enter><C-W>T

It will create a mapping that is local to the quickfix buffer (it also works in location lists, since they have the same filetype, i.e. qf). This mapping will first open the item under the cursor in a new window using <C-W><Enter> and then move it to an new tab using <C-W>T.

See

:help :autocmd
:help quickfix
:help CTRL-W_<Enter>
:help CTRL-W_T
share|improve this answer
    
Nice! BTW, are you stackoverflow.com/users/813602/ingo-karkat or are there disproportionately many Vim masters named Ingo? – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Mar 23 at 16:59
    
@CiroSantilli六四事件法轮功包卓轩 the latter, perhaps: vi.stackexchange.com/users/970/ingo-karkat – muru Mar 23 at 17:08

This mapping does what I think you want, put it in ~/.vim/after/ftplugin/qf.vim.

nnoremap <buffer> <CR> :tabnew\|cc <C-r>=line(".")<CR><CR>
share|improve this answer
    
How does this compare to ingo's answer: vi.stackexchange.com/a/6999/2038 At first sight, that is more readable (I understand the ftplugin vs autocmd part :-)) – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Mar 23 at 21:38
2  
You mentioned in your question that you don't want splits. Ingo's mapping opens the file in a new window and moves that window to a tab while my mapping doesn't create an intermediary window. Other than that, I'd say both get the job done. The choice is yours. – romainl Mar 23 at 22:42

The quickfix/location list is an interesting beast. I'd recommend reading into :help quickfix for some inner workings of these two features (pretty much interchangeable; list commands are prefixed with l and quickfix with q)

It sounds like the default quickfix opens won't solve your problem (opening in a new tab is not supported by default)

I'd check out QFEnter. It was built to give extra control over the quickfix menu and it looks like it should work out of the box for you.

Normal mode : Open an item under cursor in a new tab.

Visual mode : Open items in visual block in a sequence of new tabs.
Quickfix window is automatically opened in the new tab to help you open other Quickfix items.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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