If it's a file buffer (won't work for scratch buffers etc.), you can:
:let @f=@%
ENTER — in the source window;- This replaces contents of regular register f with contents of special register %, which contains current file name.
- Note: I chose register f as in file, but you can use any other register you like.
- You can verify that the register contains correct path with:
:echo @f
- Optionally: Ctrl-WCtrl-Q — to close the old window;
- gt / gT — navigate to the target tab (and window);
- Ctrl-Ws — split the tab any way you like, to open a new window;
:e␣
Ctrl-RfENTER- in the newly opened window, loads a file from the path stored in register f;
- Note: the ␣ character here marks a regular space.
Important note: the final step won't work correctly if the path contains spaces! or some special characters! :-( As a workaround, the following, slightly longer command should work for paths with spaces (though it may still fail for some other special characters):
:e␣"
Ctrl-Rf"
ENTER
(that is, quoting the result of Ctrl-R, f )
Inspired by answers from lkraav and ingo-karkat.