Skip to content

ptim/obsidian-open-vscode

 
 

Repository files navigation

Open in VSCode

This plugin for Obsidian makes a ribbon button and a command to open your vault as a Visual Studio Code workspace.

It's functionality is probably made redundant now using the Shell commands and Customizable Sidebar (or Buttons) plugins, but it'll be maintained for the foreseeable future.

You can use VSCode for various purposes with your vault, such as for git version control, markdown formatting with Prettier, linting with markdownlint, mass formatting files and more.

video showcase

The icons work with light and dark mode.

light and dark

You can also use it as a command and assign hotkeys to it. You can disable the ribbon button in settings. command

Settings

Open VSCode by executing the code command

By default the plugin uses child_process to launch VSCode with the code command, but the previous method using URLs can still be enabled by checking the following option:

Open VSCode using a vscode:// URL instead of executing the code command.

On some systems, this may be faster than using the child_process approach.

Template for executing the code command

You can template the command opening VSCode however you like with its provided command line arguments. This way you can technically launch any command you set, so take caution. Potential use cases include opening workspaces with .code-workspace files (e.g. for Dendron), opening specific files, folders, etc.

Note that on MacOS, a full path to the VSCode executable is required (generally "/usr/local/bin/code").

You can use the following variables: {{vaultpath}} (absolute), {{filepath}} (relative). The default template is code "{{vaultpath}}" "{{vaultpath}}/{{filepath}}", which opens the current file (if there is one) in the workspace that is the vault's root folder. This gets expanded to be executed in your shell as code "C:\Users\YourUser\Documents\vault" "C:\Users\YourUser\Documents\vault/Note.md", for example.

Path to VSCode Workspace

If "Use URL" is checked, VSCode will open Obsidian files in this workspace (requires an absolute path).

Open file

If "Use URL" is checked, open the current file rather than the root of the Obsidian vault.

Installation

You can install the plugin via the Community Plugins tab within Obsidian. You can also manually copy from releases to your .obsidian/plugins/open-vscode folder.

Caveats

The first time you use the URL method for opening, VSCode displays a confirmation dialog (that you just can hit enter on) for security reasons. See this issue for more infomation.

Development

Run npm install for dependencies and npm run build to build.

This plugin follows the structure of the Obsidian Sample Plugin, see further details there. Contributions are welcome.

Credits

Toggle ribbon setting by @ozntel.

Thank you to the makers of the DEVONlink plugin, as it was a great starting point for working with ribbon icons in Obsidian. The icon is from icon-icons.com and was resized with iLoveIMG.

Support

If you like this plugin you can support me on PayPal here: Paypal

About

Open vault in VSCode button for Obsidian.md

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 81.4%
  • JavaScript 18.6%