Search code examples
htmlgoogle-chromesublimetext3sublime-text-plugin

How to run the html file created in Sublime Text in Chrome directly?


I tried creating a build system in sublime text and saving as chrome:

{
  "cmd":["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe","$file"]
}

But it had no success. On running with ctrl B it shows No Build System

Note: I have selected Chrome in build system.

What I can do solve this?


Solution

  • The contents of a sublime-build file has to be valid JSON in order for Sublime to recognize it, but the build that you posted above is not valid.

    The \ character is special in JSON (as in many programming languages as well) in that it indicates that the next character should be interpreted specially, for example \n meaning "start a new line".

    In order to use a \ character in a string, you need to double it to tell the JSON parser that it's just supposed to be a regular character and not special. For example:

    {
      "cmd":["C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe","$file"]
    }
    

    Alternatively Windows generally accepts / in place of \ in paths, which depending on your preference can be a little easier to look at visually:

    {
      "cmd":["C:/Program Files (x86)/Google/Chrome/Application/chrome.exe","$file"]
    }