3

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...

jwd
  • 9,860
  • 3
  • 35
  • 59

1 Answers1

3

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++] = ' ';
    }
    ...
}
Matt
  • 11,089
  • 1
  • 10
  • 19
  • 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? – jwd Jan 30 '20 at 19:35
  • I just tried with `vim --clean`, and it seems like the default `errorformat` still has those bars for non-message lines... – jwd Jan 30 '20 at 19:42
  • @jwd 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. – Matt Jan 30 '20 at 19:56
  • 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? – jwd Jan 30 '20 at 20:01
  • @jwd No, you can't unless you patch source code (src/quickfix.c int qf_buf_add_line(buf, ...)) – Matt Jan 30 '20 at 20:20