Thursday, April 28, 2011

":windo g/pattern/q" peculiarity

Not sure if this is an old-version-of-vim thing, or if it's just
a peculiar interaction. Scenario: I had a bunch of vim-windows
open on various files and wanted to close those that contained a
given pattern (in the example below, using "@" as my pattern to
close windows with email addresses in them), so I issued:

:windo g/pattern/q

which did as I expected, but had the odd side effect of printing
misleading messages about additional/fewer lines:

193 more lines
E486: Pattern not found: @
86 fewer lines
16 fewer lines
E486: Pattern not found: @

(the E486 is ignorable because those were the files that didn't
match the pattern). No lines were actually added/removed. The
"more"/"fewer" lines likely comes from Vim noting the number of
lines before the ":g" and comparing it to number of lines after
the ":g", and reporting the difference, but not noticing that the
file/buffer/window had changed in the process.

Looks like a minor bug or underdocumentation to me, though
certainly not grievous.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: