On 2006-05-06, Sven Brueggemann <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I use Vim in diff mode (gvim.exe -d) as a diff viewer
> in a version control system (not exclusively of 
> course :-) ).
> 
> This works excellent when diffing a local file ("working
> copy") against another version of this file that the
> VCS saves to a temp file for diffing. One can easily
> distinguish both versions of the file by their name.
> 
> But when diffing two versions of a file that are both
> saved to temp files (say temp1.txt and temp2.txt) it's 
> often hard to say which is which. 
> 
> The VCS can provide window titles for both files, e.g.
> "This is revision 10 of foobar.txt" for temp1.txt and
> "This is revision 22 of foobar.txt" for temp2.txt.
> 
> I'm trying to make use of these window titles for
> ages now - with not much luck. Although I'd prefer
> a way to display the titles per window, I would
> happily accept suggestions on how to display the
> titles together in the window title of the vim instance.
> I'm almost certain that should be possible, but I'm
> struggling with the quotes that are needed, because
> the command "+set titlestring" contains spaces as
> do the windows titles provided by the VCS (these are
> already in double quotes).
> 
> Any ideas? I'm using gvim.exe 7.0g.

Here is a sketchy outline of a solution.  Use an autocommand to set 
a buffer-local variable (e.g., b:title) to the title string provided 
by your VCS.  Set the 'statusline' option to call a function instead 
of displaying the file name directly.  In that function, return the 
value of that buffer-local variable if it exists, e.g.,

    function! FileName()
        if exists('b:title')
            return b:title
        else
            return expand("%")
        endif
    endfunction

One way to solve the "set titlestring" problem is to use "let 
&titlestring = " instead.  This allows you to quote the spaces as

    let &titlestring = "Title with Spaces"

instead of

    set titlestring=Title\ with\ Spaces

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA

Reply via email to