【问题标题】:SublimeLinter "max-line-length" setting not applied未应用 SublimeLinter “max-line-length”设置
【发布时间】:2015-02-21 19:13:12
【问题描述】:

我在 SublimeText3 中为 SublimeLinter 设置用户设置时遇到了困难。我在这里检查过:http://www.sublimelinter.com/en/latest/settings.html

我尝试设置我的用户设置,并将“max-line-length”设置为 80(默认为 100):

{
    "user": {
        "debug": false,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "background",
        "linters": {
            "pylint": {
                "@disable": false,
                "args": [],
                "disable": "",
                "enable": "",
                "excludes": [],
                "max-line-length": 80,
                "paths": [],
                "rcfile": "",
                "show-codes": false
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": true,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 10,
        "show_errors_on_save": false,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "html (django)": "html",
            "html (rails)": "html",
            "html 5": "html",
            "php": "html",
            "python django": "python"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

但是,此设置不适用。我已经关闭并重新打开了 sublime text。如何应用此设置?谢谢。

【问题讨论】:

    标签: sublimetext3 sublimelinter


    【解决方案1】:

    由于此消息继续定期出现在 Google 的首页上,并且 SublimeLinter 发生了很大变化,这是我的解决方案:

    我在 sublime text 3 (screenshot) 的Command Palette 中输入“pref lint”或“preferences linter”以打开首选项文件。

    这是我正在使用的SublimeLinter.sublime-settings 默认配置文件(W0312 用于使用制表符而不是空格):

    // SublimeLinter Settings - User
    {
        "linters": {
            "pylint": {
                "filter_errors": ["warning:", "W0312"]
            }
        }
    }
    

    我使用pylint-messagessearch box 的帮助下找到正确的错误/警告代码。

    【讨论】:

      【解决方案2】:

      您使用的语法似乎适用于某些 linter,但是,据我所知,它不适用于 pylint

      无论如何,要使用 Sublime Text 中的 pylint 您可以使用命令参数 --max-line-length=N , 所以改变

      "args": []
      

      "args": ["--max-line-length=90"]
      

      此外,如果您这样做,请删除 max-line-length 属性。


      编辑:放置 SublimeLinter 设置的位置。

      您可以在SublimeLinter settings documentation了解它

      我使用了用户设置文件,您通常可以使用以下菜单选项找到该文件:Preferences > Package Settings > SublimeLinter > Settings-User。为此,您需要在 linters/pylint 中添加选项:

      {
          "user": {
              "linters": {
                  "pylint": {
                      // "exampleOtion": "exampleValue",
                      "args": ["--max-line-length=90"]
                  }
              }
          }
      }
      

      请注意,您的配置文件可能与问题中的类似,因此您只需在 "pylint" 中添加新选项,而不会破坏 JSON 格式

      【讨论】:

      • 投了反对票,因为答案没有说明将配置选项放在哪里,而且,添加配置选项也无济于事。
      • @JeffDavenport 我已经更新了答案以添加该信息。我刚刚测试过它并且它有效。如果您对此有任何问题,请随时告诉我,以便我为您提供帮助。
      • 谢谢,赞成,但是这个选项似乎只适用于 pylint 并且似乎对 SublimeLinter-haml-lint 包没有任何影响
      • 如果您将此添加到您的users 文件中,您需要删除"users": { 定义。复制和粘贴以上内容不起作用。这样做:{ "linters": { "pylint": { "args": ["--max-line-length=125"] } } }
      猜你喜欢
      • 2021-02-02
      • 2019-05-08
      • 2012-04-25
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 2013-03-05
      • 2013-11-15
      • 1970-01-01
      相关资源
      最近更新 更多