0

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

3
  • 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
    Commented Jan 25, 2023 at 12:29
  • For reading text in a PDF file, the afterimage plugin may suffice.
    – Friedrich
    Commented Jan 25, 2023 at 13:47
  • Do you have found a solution to your problem? Could you share it with us? Commented Feb 12, 2023 at 17:43

1 Answer 1

0

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
endfunction
2
  • This is super useful
    – ranemirusG
    Commented Feb 12, 2023 at 23:30
  • Welcome to Vim! Thanks for the feedback :-) Commented Feb 13, 2023 at 3:25

Your Answer

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

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