:cdo print
command (intended to print every line in the quickfix list), shows generic file information instead of line output for some quickfix entries. Why is this?
The following example is taken from Practical Vim tip 109 "Call grep Without Leaving Vim". In the code samples, the source text files are in the
code/grep
directory.)
In the example, the quickfix list is populated with three entries across two text files:
:code/grep
:grep Waldo *
:cli
1 department-store.txt:1: Waldo is beside the boot counter.
2 goldrush.txt:6: Waldo is studying his clipboard.
3 goldrush.txt:9: The penny farthing is 10 paces ahead of Waldo.
However, :cdo print
outputs unexpected text "goldrush.txt" 9 lines --11%--
for the first entry instead of Waldo is beside the boot counter.
:
(1 of 3): Waldo is beside the boot counter. "goldrush.txt" 9 lines --11%-- (2 of 3): Waldo is studying his clipboard. Waldo is studying his clipboard. (3 of 3): The penny farthing is 10 paces ahead of Waldo. The penny farthing is 10 paces ahead of Waldo.
Observations
The behavior of
:cdo print
is different from that of sister commands:{tab,arg,buf}do print
, whose output includes all applicable lines, for instance:bufdo print
:Waldo is beside the boot counter. A man has found gold.
Redirecting
:cdo print
to a register shows the expected output.:redir @a :cdo print :redir END
A subsequent
:echo @a
reveals:"department-store.txt" 5 lines --20%-- ((2) of 2) (1 of 3): Waldo is beside the boot counter. Waldo is beside the boot counter. "goldrush.txt" 9 lines --11%-- (2 of 2) (2 of 3): Waldo is studying his clipboard. Waldo is studying his clipboard. (3 of 3): The penny farthing is 10 paces ahead of Waldo. The penny farthing is 10 paces ahead of Waldo.
Compared to this, the direct output of
:cdo print
appears to be truncated.
Vim version: 8.2.800