Say in Gvim I have a line in the current buffer:


How can I access this file (~/.bashrc) in the same, or a new, or a vertical-split window?

I tried gx, which opens the file with xdg-open. It opens the file in a new Gvim session / instance, rather than in the current one.

  • 1
    Try gf instead (:h gf) – VanLaser Sep 26 '16 at 15:41

The whole point of gx is to open the file under the cursor in an external program.

Use gf to open the file in a new buffer.

Use <C-w><C-f> to open it in a new horizontal window then use <C-w>L to turn that window into a vertical one.

  • Did you mean <C-w>L to turn the window to a vertical split? – Y. Pei Sep 26 '16 at 16:01
  • Oops! Yes that's what I meant. – romainl Sep 26 '16 at 16:04

If you're using netrw to see the file you want opened: with the cursor atop the filename, press o (for a horizontal split window) or v (for a vertical split window). See :help netrw-contents and :help netrw-quickmaps . (use p for a preview window)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.