ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Open URL

by noahcoad ST2/ST3 Trending

Open URLs, files, folders, or google text under the cursor or in selected text for Sublime Text.

Details

  • 3 2018.08.09.22.44.56
    2 2013.10.15.02.11.05
  • github.​com
  • github.​com
  • 1 week ago
  • 5 minutes ago
  • 6 years ago

Installs

  • Total 15K
  • Win 8K
  • OS X 5K
  • Linux 2K
Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3
Windows 5 6 6 7 4 1 2 4 2 4 5 5 1 1 6 8 2 1 3 4 0 3 2 6 5 6 2 2 4 5 0 6 4 2 1 2 4 3 1 4 2 3 6 2 7 6
OS X 1 3 5 1 5 2 0 3 9 3 4 1 0 2 2 2 2 3 4 3 2 3 0 2 2 3 0 1 2 6 2 5 0 0 0 3 3 3 2 6 1 5 2 5 0 1
Linux 1 0 2 4 0 1 2 1 1 0 1 0 0 1 0 0 1 0 1 1 0 1 0 2 0 1 0 0 2 0 1 2 0 0 1 0 1 0 1 1 1 0 1 2 3 1

Readme

Source
raw.​githubusercontent.​com

Open URL

Description

Quickly open files, folders, or web URLs from anywhere in Sublime Text.

Install

Look for Open URL using the Package Manager

How to use

Put the cursor inside a file / folder / URL / word and run the command. It automatically expands the selection until it hits delimiter chars, which can be changed in the settings (see below).

Alternatively, highlight the text you want to open. If text is highlighted the selection is not expanded.

Here's a bunch of ways you can run the command.

  • ctrl+u
  • right-click > Open URL
  • alt + double-click
  • shift+cmd+p, then look for Open URL

Give it a try

Copy the items below to Sublime Text. Place your cursor inside any one of them and hit ctrl+u.

How does it work?

If your selection is a file or a folder, you can choose to edit it (open with Sublime Text), or reveal it (open with macOS Finder/Windows File Explorer/Linux File Manager).

Opening files and folders is super convenient. Both can be specified with absolute paths, paths relative to the currently open file, or paths relative to the root of the currently open project. Env vars and the alias ~ are expanded.

If your selection is a URL, it opens immediately in a new tab in your default web browser. You can omit the scheme (http://) if you want and Open URL will add it for you.

If your selection is none of the above, you'll be presented with two options:

  • modify the selection and try again
  • search for the selection using one of your configured web_searchers
    • the only web searcher that ships with Open URL is Google search
    • to add others, read more in the “Settings” section below

Shortcuts

Don't want to choose from menu items to open a file or a folder? Look for Open URL (Skip Menu) in the Command Palette. To create a key binding for this, open Preferences: Key Bindings from the Command Palette, and add the following:

{ "keys": ["your+key+binding"], "command": "open_url", "args": { "show_menu": false } },

This will open files in Sublime Text for editing, or reveal folders in the Finder, without showing the menu first.

Running commands on files or folders

Open URL provides a few settings you can configure to run custom commands on files or folders:

  • folder_custom_commands
  • file_custom_commands
  • autoactions

Read more below.

Settings

To customize these, hit shift+cmd+p to open the Command Palette, and look for Open URL: Settings.

  • delimeters
    • characters at which auto-expansion of selected path stops, e.g. \t\n\r\"',*<>[]()
    • the default settings are Markdown friendly
  • web_browser
    • the browser that Open URL uses to open new tabs; must be a string from this list
    • if you use an empty string, the “default browser” will be used
    • if you choose a browser that's not installed on your machine, Open URL will complain
  • web_searchers
    • if your selection isn't a file, a folder, or a URL, you can choose to pass it to a web searcher, which is just a URL that searches for the selected text
    • example: { "label": "google search", "url": "http://google.com/search?q=", "encoding": "utf-8" }
  • file_custom_commands
    • pass a file to any of these shell commands, run in a subprocess
  • folder_custom_commands
    • pass a folder to any of these shell commands, run in a subprocess
    • example: { "label": "open in terminal", "commands": [ "open", "-a", "/Applications/iTerm.app" ] }
  • folder_extra_commands
    • set to this to false if you want to disable the following folder commands: ('add to sublime project', 'new sublime window')
  • file_extra_commands
    • set to this to false if you want to disable the following file commands: ('run', 'new sublime window', 'system open')
  • autoactions
    • you can set specific file extensions to be edited or run without having to choose from any options
    • if the action is edit it will be opened for editing in Sublime Text
    • if the action is run it will be executed by the OS
    • you add an 'openwith': 'myprogram.exe' to specify a specific a program to open the file with
    • in this case the shell will execute the openwith program and the selection will be a parameter

Finally

See also: Google Spell Check.

Credits: Thanks goes to peterc for starting a forum thread about this topic and KatsuomiK for his gist, which were the inspiration for this plugin.

Author: @noahcoad writes software for the heck of it and to make life just a little more efficient.

Maintainer: @kylebebak.