3

In order to work with files faster, I need to open some of them in a specific encoding depending on the file type. The only solution I found was this, but the topic starter needed something different than I am and his solution won't wok for me.

2
  1. create a copy of Text.sublime-package from Package folder that is in Program Files (of course, if you use Windows);
  2. unzip Text.sublime-package;
  3. rename Plain text.tmLanguage to EXT.tmLanguage;
  4. edit EXT.tmLanguage by modifying "content" of two keys: fileTypes and name. E.g., in my case edited XML looked like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>fileTypes</key>
        <array>
            <string>ascii</string>
            <string>nfo</string>
        </array>
    
        <key>name</key>
        <string>ASCII art</string>
    
        <key>patterns</key>
        <array>
        </array>
    
        <key>scopeName</key>
        <string>text.plain</string>
    </dict>
    </plist>
    
  5. zip EXT.tmLanguage (it seems that you may use compression);
  6. rename archive into EXT.sublime-package.

After that do as Mrsonord have described:

  1. go to Preferences > Settings – More > Syntax Specific – User;
  2. in newly opened file paste the string below (in my case SublimeEncodingName was DOS (CP 437)):

    {
        "default_encoding": "%SublimeEncodingName%",
        "fallback_encoding": "%SublimeEncodingName%",
    }
    
  3. save the file.
| improve this answer | |
1
  1. Either:
    • Browse packages and create a file EXT.sublime-settings(Note the caps on filetype ext).
    • While editing the filetype you wish to modify settings for: Preferences->Settings - More->Syntax Specific - User
  2. Enter your desired encoding options as the example below.

{ "default_encoding": "UTF-8", "fallback_encoding": "utf-8" }

| improve this answer | |
  • It doesn't work. When I'm opening my file, which by default is Plain text, and run command Syntax Specific - User file EXT.sublime-settings is created automatically, but it is of the type Plain text. When I manually create EXT.sublime-settings nothing happens as well. The only possible solution I've found (haven't tested) is to create new syntax file in Program Files under Packages, like Markdown.sublime-package (zipped file with XML describing settings for the file type). – Pugsley Apr 30 '14 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.