In Windows OS, it is possible to open a LaTeX-generated PDF file with TeXworks and when you press ctrl+click on the PDF file TeXworks editor is opened. I was wondering how we can make Visual Studio Code the default editor such that ctrl+click on the PDF file will open vscode instead. I think this question which tries to set WinEdt as the default editor is relevant, but I don't know how to set vscode as the opening editor.

  • 1
    Use another PDF viewer like sumatra and specify vscode for backward synchronization (synctex). – TeXnician Mar 18 at 7:33
  • 1
    @TeXnician I have also asked a question here to see how vscode can be set to work with sumatra PDF. – Opt Mar 18 at 7:38

Most PDF viewers that are aware of SyncTeX can be easily configured to reverse (inverse) sync. Such viewers are Evince, Okular, SumatraPDF etc. Some editors (not all) can be started from the PDF if the SyncTeX file is present alongside the PDF (one reason not to delete them) when the inverse command is triggered (double click for SumatraPDF or shift left click for Okular, and Control click for some others, it depends on the viewer).

For collaborative working it is possible to embed the SyncTeX file inside the portfolio PDF and SumatraPDF can readily extract it to the pdf folder in order to trigger any users editor not just the one used to compile. (NOTE compile would require 1 pass to build synctex then a second method to embed it, but that's a separate workflow question beyond this guide)

You asked elsewhere how you could to do that using SumatraPDF and for your VScode desire you will find in this guide the following command entry but you need to use the location of your VS code editor in place of \editor\code NOTE the last character is lower case L

Okular tends to share the same combination of tokens as SumatraPDF but Evince and others may be different.

Microsoft VS Code = "\editor\Code.exe" -g %f:%l 

you may need to try "%f:%l" or "%f":%l or even other escape chars depending on system

Why some other editors won't start that way easily is that they may require a "server" daemon to be active and running first in order to catch the tex file open command. Such examples that need some prior trigger are LyX (uses a pipe) TeXlipse (requires java service) several others that use DDE (TeXnicCenter) or d-bus etc.

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.