Skip to main content
added 292 characters in body
Source Link
akavel
  • 131
  • 2

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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! :-(

Inspired by answers from lkraav and ingo-karkat.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

add note about spaces
Source Link
akavel
  • 131
  • 2

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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! :-(

Inspired by answers from lkraav and ingo-karkat.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

Inspired by answers from lkraav and ingo-karkat.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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! :-(

Inspired by answers from lkraav and ingo-karkat.

replaced http://vi.stackexchange.com/ with https://vi.stackexchange.com/
Source Link

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

Inspired by answers from lkraavlkraav and ingo-karkatingo-karkat.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

Inspired by answers from lkraav and ingo-karkat.

If it's a file buffer (won't work for scratch buffers etc.), you can:

  1. :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
  2. Optionally: Ctrl-WCtrl-Q — to close the old window;
  3. gt / gT — navigate to the target tab (and window);
  4. Ctrl-Ws — split the tab any way you like, to open a new window;
  5. :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.

Inspired by answers from lkraav and ingo-karkat.

Source Link
akavel
  • 131
  • 2
Loading