bufdo not working?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bufdo not working?

Bill Weir
Here are two files:

$ cat file1
FILE1 line1
FILE1 line2
$ cat file2
FILE2 line1
FILE2 line2

If I edit them both with gvim (version 6.3), and then run this command:

    :bufdo g/./p

this is what I see:

    "file1" 2L, 24C
    FILE1 line1
    "file2" 2L, 24C
    FILE2 line1
    FILE2 line2

What happened to the second line of file1?

--
Bill



Reply | Threaded
Open this post in threaded view
|

Re: bufdo not working?

Tim Chase-2
> :bufdo g/./p
>
> this is what I see:
>
> "file1" 2L, 24C FILE1 line1 "file2" 2L, 24C FILE2 line1 FILE2
> line2
>
> What happened to the second line of file1?

It was overwritten by the '"file2" 2L, 24C' text.  The usual
workaround for this that I've seen is to do

:bufdo exe "g/./p" | echo

which prints an extra line-feed at the end of each file, to
ensure that the '"filename" Lines, Chars' bit starts on a new
line.  It does have the unfortunate side effect that you get one
extra newline at the end of the whole lot, but it's pretty easy
to ignore :)

I'm not sure whether it's classified as a bug, or if there's some
setting that may cure this symptom, but that's a quick fix, FWIW.

HTH,

-tim





Reply | Threaded
Open this post in threaded view
|

Re: bufdo not working?

Bill Weir
Tim Chase wrote on 16/06/2005 15:45:

>> :bufdo g/./p
>>
>> this is what I see:
>>
>> "file1" 2L, 24C FILE1 line1 "file2" 2L, 24C FILE2 line1 FILE2
>> line2
>>
>> What happened to the second line of file1?
>
>
> It was overwritten by the '"file2" 2L, 24C' text.  The usual
> workaround for this that I've seen is to do
>
> :bufdo exe "g/./p" | echo

That doesn't work for me - just produces the same output as my original
posting.  However, this variant does work (on UNIX at least):

    :bufdo exe "g/./p" | !:

Thanks for the pointer.

--
Bill