On So, 24 Nov 2013, [email protected] wrote:

> Hello VIM developers,
> 
> There is a problem when working with switchbuf=useopen and :sb -alternate 
> buffer is not updated correctly;
> 
> To reproduce:
> 
> vim -u NONE
> :set swb=useopen
> :new a
> :new b
> :new c
> :ls (just checking - c is %, b is #)
> :sb a
> :ls (a became % as expected, but the alternate buffer is now b while I'd 
> expect it to be c)
> 
> I'm runnign VIM 7.4.103 on linux, but I think it is an old issue.

I looked it up in the code and to my surprise it is not a bug but a 
feature. The alternate filename is window local, thus it depends on the 
window in which you issue the :ls command what '#' will be expanded to. 
You can check by running :windo :ls and see the difference.

I suggest, that this is documented, something like this patch:

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -754,6 +754,7 @@
 function expand() |expand()|.
        %       Is replaced with the current file name.           *:_%* *c_%*
        #       Is replaced with the alternate file name.         *:_#* *c_#*
+               (Note: is window-local.)
        #n      (where n is a number) is replaced with            *:_#0* *:_#n*
                the file name of buffer n.  "#0" is the same as "#".     *c_#n*
        ##      Is replaced with all names in the argument list   *:_##* *c_##*
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -38,6 +38,8 @@
 file name.  It can be used with "#" on the command line |:_#| and you can use
 the |CTRL-^| command to toggle between the current and the alternate file.
 However, the alternate file name is not changed when |:keepalt| is used.
+Note, that the alternate-file is local to a window (thus it can be different
+depending on the window the cursor is on).
 
                                                        *:keepalt* *:keepa*
 :keepalt {cmd}         Execute {cmd} while keeping the current alternate file

Best,
Christian
-- 
Und ich behaupte, daß ein Mensch, der nicht unter der einen oder
anderen Form gewohnt ist, aufrührerischen Gedanken nachzugehen, vom
rein menschlichen Standpunkt aus betrachtet, eine defekte
Geistesverfassung besitzt.
                -- Gilbert Keith Chesterton

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui