Vim Quickfix prefixes double-bar "||" — explain?
Asked Answered
N

2

6

I use the Quickfix view in Vim often. The text in there always has a prefix of || added to it.

So, for instance, when I copy/paste out of that buffer, etc. I get those characters included by default.

Is there a way to disable this? I haven't had luck finding any documentation or configuration for this...

Nemato answered 30/1, 2020 at 18:56 Comment(0)
M
1

It is now possible to customize the display of the quickfix window.

vim has introduced the quickfixtextfunc (:h qftf).

It allows exactly to customize the rendering of the quickfix window. The documentation includes an example, you can also see an example in the nvim-bqf README, although it's neovim/lua based.

You can see an example in the vim documentation in :h quickfix-window-function.

To implement a general-purpose qftf (not a specific one as in the vim documentation), you should start similarly than in the nvim-bqf readme, meaning, check if the info parameter quickfix field is 1, you should display items from getqflist, otherwise items from getloclist

Morphology answered 16/7, 2022 at 15:29 Comment(0)
B
4

Quickfix buffer is supposed to be used for parsing specially formatted strings (like compiler messages). This is done with the help of :h 'errorformat' option. And those "bars" are output separators between "filename", "line number" and "the message body".

If you have only "double bars" at the beginning of a line then you either have errorformat set wrong, or you misuse the quickfix buffer.

UPD. If you're interested, "Bars" are hardcoded in Vim's source (src/quickfix.c):

static int
qf_buf_add_line(buf_T *buf, linenr_T lnum, qfline_T *qfp, char_u *dirname)
{
    ...
    if (qfp->qf_module != NULL)
        ...
    if (len < IOSIZE - 1)
        IObuff[len++] = '|';
    if (qfp->qf_lnum > 0)
        ...
    if (len < IOSIZE - 2)
    {
        IObuff[len++] = '|';
        IObuff[len++] = ' ';
    }
    ...
}
Breathy answered 30/1, 2020 at 19:15 Comment(5)
There is plenty of compiler output that does not include a file/line number, but is still useful. Are you saying those lines should not have a || prefix?Nemato
I just tried with vim --clean, and it seems like the default errorformat still has those bars for non-message lines...Nemato
@Nemato There's a :compiler command to load a right script from compiler/ subdirectory, which, in turn, provides errorformat presets. If your tool is not supported by Vim read :h write-compiler-plugin and do it yourself. There can be no "universal" solution suitable for every external program out there.Breathy
I'm not sure I'm being clear: I am using a normal compiler, and the messages that it produces have their file/line numbers parsed fine in the quickfix view (I can jump to them, etc). But there is additional text that the compiler outputs, which also shows up in quickfix, and I'm wondering if there's some way to tell Vim that those lines are just plain text, and thus don't need any ||. Does that make sense?Nemato
@Nemato No, you can't unless you patch source code (src/quickfix.c int qf_buf_add_line(buf, ...))Breathy
M
1

It is now possible to customize the display of the quickfix window.

vim has introduced the quickfixtextfunc (:h qftf).

It allows exactly to customize the rendering of the quickfix window. The documentation includes an example, you can also see an example in the nvim-bqf README, although it's neovim/lua based.

You can see an example in the vim documentation in :h quickfix-window-function.

To implement a general-purpose qftf (not a specific one as in the vim documentation), you should start similarly than in the nvim-bqf readme, meaning, check if the info parameter quickfix field is 1, you should display items from getqflist, otherwise items from getloclist

Morphology answered 16/7, 2022 at 15:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.