I have a text file with lots of links to local directories which cointains .pdf files.

I know about gf, but is there a way to open only the directory and not the file?

For example, from this link ~/myDir/subfolder/file.pdf jump to /subfolder

or even better open the .pdf in a pdf reader from vim

Thanks in advance for your insights and experience

  • If you don't have much use of gF, remap it to do :browse based on the cursor position? Better, map it to :Explore (see :help netrw)
    – gildux
    Jan 25 at 12:29
  • For reading text in a PDF file, the afterimage plugin may suffice.
    – Friedrich
    Jan 25 at 13:47
  • Do you have found a solution to your problem? Could you share it with us? Feb 12 at 17:43

1 Answer 1


You should be able to configure the gx command to open the pdf file.

The netrw plugin has to be active and you may have to adapt the following .vimrc code to your platform.

let g:netrw_browsex_viewer = "-"
function! NFH_pdf(filename)
  " Add the call to open a:filename on your platform
  • This is super useful
    – ranemirusG
    Feb 12 at 23:30
  • Welcome to Vim! Thanks for the feedback :-) Feb 13 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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