Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcut/"Open with" Sublime Text, in a new Sublime window

I am looking for a way to right click a file in Windows 10, select "Open with" -> "Sublime Text", and then have a new Sublime Text window appear.

The default action is to open the file in a new tab, if Sublime is already open. This is usually not what I want, especially since I usually have Sublime open on a different desktop.

I've tried making a shortcut with the -n flag added, which correctly gives me a new window when just using the shortcut. But when I "Open with" using that shortcut it opens the file in an existing window.

I also tried "Open with" a batch file containing subl -n, ``but alas.

like image 815
Filip S. Avatar asked Nov 19 '15 07:11

Filip S.


1 Answers

This works for me (and is more comfortable for me than the Open with submenu):

  1. Open regedit.exe
  2. navigate to HKEY_CLASSES_ROOT\*\shell
    To apply this only to certain file types replace the * with the appropiate extension
  3. Add key "Open With sublime in new window"
  4. Inside this, add new key "command"
  5. Inside "command" set the (Default) string to:
    C:\Program Files\Sublime Text 2\sublime_text.exe -n "%1"

(basically copy the original keys, adding the -n)

  1. Optional:
    Inside the key "Open With sublime in new window", add a string named Icon:
    C:\Program Files\Sublime Text 2\sublime_text.exe,0
    This will add an the Sublime Text icon to the left of the command on the right-click menu.

To add the entries to the context menu for folders, add the same entries in:

  • HKEY_CLASSES_ROOT\Folder\shell
    For the context menu when you click on a folder icon
  • HKEY_CLASSES_ROOT\Directory\Background\shell
    For the context menu when you click on the background of a folder
    For this entry you must replace "%1" with "%V" (Thanks Filip)
like image 171
Gerald Schneider Avatar answered Sep 17 '22 22:09

Gerald Schneider