Why does the vim gt command does not set alternate file as expected? -


launch vim without arguments, , perform experiment. files a, b, c , d used in experiment below need not exist.

  1. execute :e a
  2. execute :tabe b
  3. execute :tabe c
  4. execute :tabe d
  5. execute :ls
  6. press enter remove output of previous command
  7. execute gt
  8. execute :ls

this output of step 5.

:ls   1    "a"                            line 0   2    "b"                            line 0   3 #a   "c"                            line 0   4 %a   "d"                            line 1 press enter or type command continue 

this shows "c" alternate file (marked #) , "d" current file (marked %). far, see expected per documentation. if there existing current file, becomes alternate file when make other file current file.

but output of step 8 following.

:ls   1 %a   "a"                            line 1   2    "b"                            line 0   3    "c"                            line 0   4    "d"                            line 0 press enter or type command continue 

now "a" has become current file expected. marked %. "d" has not become alternate file now. file "d" not marked # anymore. why hasn't "d" become alternate file?

the "alternate file" previous file edited.

until switch buffers, matters order of creation of buffers, not order of access.

you edited a, b, c, d:

  • a "alternate file" of b,
  • b "alternate file" of c,
  • c "alternate file" of d.

because a first file edited there's no "previous file" doesn't have "alternate file".

because d last file edited not "alternate file" of anything. "alternate file" of next file edit.

gt didn't make d "alternate file" of a because didn't edit a after d or d after a.

do :b a or :tabedit a while in d , d "alternate file" of a.

as pointed out others, experienced 1 of many drawbacks of using tab pages you'd use tabs in other editors. fine problem designed solve have millions ways suck if insist on treating them file proxies.

the whole notion of "alternate file" navigation feature that's only applicable buffers.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -