Sublime Forum

Error in my installation

#1

Hi There!

Every time I open Sublime Text I have this message:
Error trying to parse file: Unexpected character, expected a comma or closing bracket in Packages/User/Default (OSX).sublime-keymap:2:8

I trashed the app and reinstalled it but I still see that message.
How can I uninstall sublime text and start from scratch. Obviously, after installing a bunch of plugins I’ve done something wrong.

Help please,

Thanks!

boco

0 Likes

#2

It’s telling you that you have a Default keymap in your User folder that has an issue. It is even telling you what line the error is on with a description of the issue. Try opening that file and fixing the issue it describes.

0 Likes

#3

That error message is telling you that the file mentioned is broken at line 2, column 8 (that’s what the :2:8 means. In particular the file name indicates that your key bindings for OSX are broken at that location.

The number of issues that you can resolve by uninstalling and reinstalling Sublime is incredibly low due to the fact that all configuration and packages that you install go into a location in your user folder that’s outside of the application folder, so removing Sublime and installing it again leaves you with the same configuration and packages that you started with.

To fix your problem, once Sublime starts up (and you close that error dialog), select Sublime Text > Preferences > Key Bindings. The offending file will be in the right hand pane of the newly created window. Check at the indicated position to see what might be wrong.

The sublime-keymap file is JSON, so common problems are things like forgetting to include a comma, forgetting to close a string with a double quote, etc. You can try passing your config through JSONlint.com. but note that Sublime’s JSON parser is slightly more tolerant than standard JSON (i.e. it allows comments and redundant trailing commas) so you may need to edit things.

In a pinch you can replace the contents of the file with [] to reset it back to what it contained when you first installed.

2 Likes

#4

Thanks for your answer and it does make sense. I suspected that it was something like that and followed your suggestion but I can’t find the error - here is what I have and can’t see the fault:
“keys”: [“super+shift+r”], “command”: “browser_refresh”, “args”: {
“auto_save”: true,
“delay”: 0.0,
“activate”: true,
“browsers”: [“chrome”]
}

0 Likes

#6

That works fine for me; note however that as posted above, you’re missing the {} pair that wrap the entire key binding definition and group it together as a single definition. Assuming that’s not just a copy/paste error, that may be the source of your problem.

It’s also important that the bindings be contained in a pair of [], since it is a list of JSON objects where each object is a key binding.

For example, a complete Default (OSX).sublime-keymap file that contains only this custom mapping would look like this:

[
    {
        "keys": ["super+shift+r"], "command": "browser_refresh", "args": {
            "auto_save": true,
            "delay": 0.0,
            "activate": true,
            "browsers": ["chrome"]
        }
    },
]

As mentioned above, Sublime’s JSON parser is slightly more lenient than the standard. In particular this shows a trailing comma after the key binding which is technically illegal in JSON, but Sublime allows it. As a result of that it’s always safe to include a binding in the list with a trailing comma and know that it’s going to work as expected.

1 Like

#7

Great! The error is gone. Now I’m trying to make the Browser Refresh working which is not the case right now.

Thanks much!

0 Likes