Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 keyboard shortcut to open file in specified browser (e.g. Chrome)

Tags:

sublimetext2

I do web development and am trying out Sublime Text 2. Is there a keyboard shortcut to open the current file in specified browser (e.g. Chrome)?

Any help to get setup in Sublime Text for web development is appreciated!

like image 371
wwwuser Avatar asked Nov 05 '11 22:11

wwwuser


People also ask

Is there a keyboard shortcut to open Chrome?

So, if you want to make Ctrl+Alt+C your shortcut key for launching Google Chrome, just press “C”.

What does Ctrl d do in Sublime Text?

Ctrl + D in SublimeText is "Quick Add Next." This appears to be equivalent to Ctrl + B in Brackets, which is "Add next match to Selection" on the Find menu.


2 Answers

I'm not really sure this question is approprate here, but you can add a new "Build System" under Tools -> Build System -> New Build System...

As with all configuration in Sublime Text its just JSON, so it should be pretty straight forward. The main thing you are going to want to configure is the "cmd" key/val. Here is the build config for launching chrome on my mac.

{     "cmd": ["open", "-a", "Google Chrome", "$file"] } 

Save that as Chrome.sublime-build, relaunch Sublime Text and you should see a new Chrome option in the build list. Select it, and then you should be able to launch Chrome with Cmd+B on a Mac (or whatever hotkey you have configured for build, maybe its F7 or Ctrl+B on a Windows machine)

At least this should give you a push in the right direction.

Edit:

Another thing I end up doing a lot in Sublime Text 2 is if you right click inside a document, one of the items in the context menu is Copy File Path, which puts the current file's full path into the clipboard for easy pasting into whatever browser you want.


Sublime Text 3 (linux example) "shell_cmd": "google-chrome '$file'"

like image 163
J. Holmes Avatar answered Oct 10 '22 11:10

J. Holmes


"Open in Browser context menu for HTML files" has been added in the latest build (2207). Its release date was 25 June 2012.

like image 40
aanton Avatar answered Oct 10 '22 10:10

aanton