SublimeText encloses lines in white rectangles

2019-01-10 02:35发布

It's rather annoying and I can't seem to figure out why.

enter image description here

12条回答
贼婆χ
2楼-- · 2019-01-10 03:33

If you are using Anaconda plugin (for Python development) this is it's linting functionality - it highlights Python syntax errors and PEP8 violations.

You can disable this feature completely or change the color of this outline by adding some custom rules to your current SublimeText theme:

  1. In Sublime Text menu: Preferences > Browser Packages...
  2. Locate source file of your current theme in opened directory (*.twTheme file with the name corresponding to the one, selected in Preferences > Color Scheme > ...)
  3. Duplicate this file, add another name (for example Tomorrow-my.tmTheme from Tomorrow.tmTheme)
  4. Paste the following code to this newly created theme file, right before </array> tag:

    <dict>
      <key>name</key>
      <string>anaconda Error Outline</string>
      <key>scope</key>
      <string>anaconda.outline.illegal</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#FF4A52</string>
        <key>foreground</key>
        <string>#FFFFFF</string>
      </dict>
    </dict>
    <dict>
      <key>name</key>
      <string>anaconda Error Underline</string>
      <key>scope</key>
      <string>anaconda.underline.illegal</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#FF0000</string>
      </dict>
    </dict>
    <dict>
      <key>name</key>
      <string>anaconda Warning Outline</string>
      <key>scope</key>
      <string>anaconda.outline.warning</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#DF9400</string>
        <key>foreground</key>
        <string>#FFFFFF</string>
      </dict>
    </dict>
    <dict>
      <key>name</key>
      <string>anaconda Warning Underline</string>
      <key>scope</key>
      <string>anaconda.underline.warning</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#FF0000</string>
      </dict>
    </dict>
    <dict>
      <key>name</key>
      <string>anaconda Violation Outline</string>
      <key>scope</key>
      <string>anaconda.outline.violation</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#ffffff33</string>
        <key>foreground</key>
        <string>#FFFFFF</string>
      </dict>
    </dict>
    <dict>
      <key>name</key>
      <string>anaconda Violation Underline</string>
      <key>scope</key>
      <string>anaconda.underline.violation</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#FF0000</string>
      </dict>
    </dict>
    
  5. Adjust the colors to your needs. Save file.
  6. Select your "new" theme in Preferences > Color Scheme > and observe the changes.

Point 3. was needed in my case because color wasn't updated immediately, after just saving theme and restarting Sublime/switching themes (sublime uses some kind of buffer?..). So, maybe you will have to repeat steps 3-6, when you want to play a little with the colors.

Source: Anaconda's Docs

查看更多
乱世女痞
3楼-- · 2019-01-10 03:33

If none of the previous solutions worked for you, try this:

  1. Go to Preferences | Package Settings | Pylinter | User settings
  2. In the file, just add/modify the following lines:

    "run_on_save": false,
    "disable_outline": true
    

It worked for me, and in my case I had anaconda only as a folder, associating the python compiler of Sublime to the python compiler (python.exe) present in the anaconda folder.

查看更多
趁早两清
4楼-- · 2019-01-10 03:34

Looks like you have SublimeLinter installed. It highlights errors and warnings.

查看更多
beautiful°
5楼-- · 2019-01-10 03:34

For Anaconda/Sublime Users

I have Anaconda and the lint function is useful, but out of the box, it is draconian about style. When you hover over the rectangle, it will tell you the number of the rule it is enforcing. You can disable the ones that you feel are unneeded or get in the way as you code.

On Macs:

  1. Go to Preferences | Browse Packages | Anaconda | Anaconda.sublime-settings
  2. Search for "pep8_ignore"
  3. Add the rules you want to remove.

I've put in my list the following rules that remove some of the white space rules that slow me down but keeps the "no tabs" rule.

    "E201",
    "E202",
    "E203",
    "E302",
    "E309",
    "W291",
    "W293",
    "W391"

You'll want to set "translate_tabs_to_spaces": true in your user settings if you go with this list.

Alternatively you can set "pep8" to false to stop it entirely.

查看更多
甜甜的少女心
6楼-- · 2019-01-10 03:34

if you got the anaconda linting

go in the dir like this C:\Users\giova\AppData\Roaming\Sublime Text 3\Packages\Anaconda and change the anaconda.sublime-settings (find the anaconda linter keys and set them to false). See if you installed other linter stuff and change their settings to false where it seems to rely on linting until everythings is right for you. I had installed different linters, so I had to change all of them.

查看更多
姐就是有狂的资本
7楼-- · 2019-01-10 03:39

In Anaconda with Sublime Text, if you don't want to make any changes to the settings:

In the case highlighting occurs, you can use a keyboard shortcut (in my case it's CTRL-ALT-R) to autoformat the code! The highlighting will be gone immediately.

You just have to repeat that every once in a while, after having added new code (which is not formatted according to the PEP8 rules).

The command is "anaconda_auto_format".

查看更多
登录 后发表回答