如何在Sublime Text 3中捕获错误

fdsafdsafdsafdsaf

fdsafdsafdsafdsaf

Linting is the process used to make sure that our files are error free. Making sure we have a good linting program is a smart way to avoid small errors during development. Sublime Text doesn't come with any linters built in, but we can easily add them.

整理是用于确保我们的文件没有错误的过程。 确保我们有一个好的棉绒程序是避免开发过程中出现小错误的明智方法。 Sublime Text没有内置任何短毛绒,但是我们可以轻松添加它们。

By linting, we can avoid the little errors that we've all been caught up on, like missing a semicolon. Once Sublime Linter is installed, you'll be able to see the errors in the Sublime Text gutter. Once you click on the offending line, an explanation will be given in the status bar.

通过整理,我们可以避免遇到所有小错误,例如缺少分号。 安装Sublime Linter后,您将能够在Sublime Text天沟中看到错误。 在您点击违规行后,状态栏中将给出说明。

linter-fill

Sublime Linter 3 is a plugin for Sublime Text that provides the framework to lint all the programming languages we use for development.

Sublime Linter 3是Sublime Text的插件,提供了用于整理我们用于开发的所有编程语言的框架。

使用Sublime Linter 3 (Using Sublime Linter 3)

The biggest change between this and other versions of Sublime Linter is that a new package must be installed for each of the languages that we need to lint.

此版本与Sublime Linter的其他版本之间的最大变化是, 必须为我们需要使用的每种语言安装新的软件包

For instance, if we need to lint JavaScript, PHP, and CSS, we'll need four packages:

例如,如果需要添加JavaScript,PHP和CSS,则需要四个软件包:

  1. SublimeLinter

    崇高的林特
  2. SublimeLinter-php

    SublimeLinter-php
  3. SublimeLinter-jshint

    SublimeLinter-jshint
  4. SublimeLinter-csslint

    SublimeLinter-csslint

The quickest way to get those packages is to install using Package Control and the command palette (ctrl + shift + p).

获得这些软件包的最快方法是使用软件包控制和命令面板( ctrl + shift + p )安装。

Each of those specific packages also has their own types of installation requirements and you'll need to look through each package's installation instructions.

这些特定软件包中的每个软件包都有其自己的安装要求类型,您需要仔细阅读每个软件包的安装说明。

Here are the requirements for the above packages:

以下是上述软件包的要求:

Linting PHP(需要PHP) (Linting PHP (requires PHP))

Make sure that you have the SublimeLinter-php package installed and the other requirement is to have php installed on your computer.

确保已安装SublimeLinter-php软件包,另一个要求是在计算机上安装php

That's it!

而已!

linter-php-error

整理JavaScript(需要jshint) (Linting JavaScript (requires jshint))

You will need the SublimeLinter-jshint package, but this one requires a few more things. You will need to have jshint installed on your computer.

您将需要SublimeLinter-jshint软件包,但这需要更多的东西。 您将需要在计算机上安装jshint

To install JSHint, you will need node and npm. After you have node and npm, you'll need to install the jshint package using npm (node's package manager).

要安装JSHint,您将需要node和npm 。 拥有节点和npm之后,需要使用npm(节点的软件包管理器)安装jshint软件包。

$ npm install -g jshint

The -g means that you are installing jshint globally and it will be usable by your system. Once that happens, you'll be able to see all your errors:

-g表示您正在全局安装jshint,它将被系统使用。 一旦发生这种情况,您将能够看到所有错误:

linter-js-error

If you want to install any more packages, be sure to look at its installation instructions and see what dependencies that specific package needs.

如果要安装更多软件包,请确保查看其安装说明,并查看特定软件包需要哪些依赖项。

整理模式 (Linting Modes)

Sublime Linter provides many different customizations and configurations. One of those options is the linting modes. This option changes when you see errors.

Sublime Linter提供了许多不同的自定义和配置。 这些选项之一是起毛模式。 看到错误时,此选项会更改。

  • Background: This is the default behavior of Sublime Linter. Errors will be shown as you type and are updated every time you make a change.

    背景 :这是Sublime Linter的默认行为。 输入时将显示错误,并且每次进行更改时都会更新。
  • Load/save: The background setting will show you errors even before you're done typing a function. This can be annoying for some and you can change linting to only happen on load/save.

    加载/保存 :即使在您完成输入功能之前,后台设置也会向您显示错误。 对于某些人来说这可能很烦人,您可以将棉绒更改为仅在加载/保存时发生。
  • Save only: Only lint on save.

    仅保存保存时仅掉毛。
  • Manual: You'll have to trigger a lint through the command palette.

    手动 :您必须通过命令面板触发一个皮棉。

I personally prefer the load/save setting. This way, Sublime Linter stays out of your way until you save. The background setting can get annoying as it constantly tells you that your code has errors (even though you aren't even done writing it!)

我个人更喜欢加载/保存设置。 这样一来,Sublime Linter便不会妨碍您进行保存。 后台设置会很烦人,因为它不断告诉您代码有错误(即使您甚至还没有写完它!)

更改整理模式 (To Change Linting Mode)

To change the linting mode, just go into your command palette and type:

要更改起毛模式,只需进入命令面板并输入:

sublimelinter lint mode

升华棉绒模式

You can see the setting in the command palette and change it from there.

您可以在命令面板中查看设置,然后从那里进行更改。

choose-lint-mode

标记样式 (Mark Style)

The mark style is how the code will look with an error. The default is outline but choose whichever you like based on personal preference.

标记样式是代码出现错误时的外观。 默认值为大纲,但可以根据个人喜好选择任意一个。

Taken from the Sublime Linter site, the following are the options:

以下是从Sublime Linter网站上获得的选项:

  • fill

  • outline

    大纲
  • solid underline

    下划线
  • squiggly underline

    下划线
  • stippled underline

    点划线

Just like the lint mode, you can change the mark style from the command palette. Just look for Sublime Linter: Choose Mark Style.

就像皮棉模式一样,您可以从命令面板更改标记样式。 只需寻找Sublime Linter:选择标记样式

(Fill)

linter-fill

大纲 (Outline)

linter-outline

下划线 (Solid Underline)

linter-underline

弯曲的下划线 (Squiggly Underline)

linter-squiggly-outline

点划线 (Stippled Underline)

linter-stippled-outline

天沟主题 (Gutter Themes)

In addition to mark styles, you can also change the gutter icon that shows up next to the error. Taken from the Sublime Linter docs, the following are your options

除了标记样式,您还可以更改错误旁边显示的装订线图标。 摘自Sublime Linter文档 ,以下是您的选择

蓝莓-十字架 (Blueberry - cross)

sublime-linter-blueberry-cross

蓝莓-圆形 (Blueberry - round)

sublime-linter-blueberry-round

(Circle)

sublime-linter-circle

丹麦皇室 (Danish Royalty)

sublime-linter-danish-royalty

(Hands)

sublime-linter-hands

旋钮-简单 (Knob - simple)

sublime-linter-knob-simple

旋钮-符号 (Knob - symbol)

sublime-linter-knob-symbol

科洛里亚 (Koloria)

sublime-linter-koloria

项目图标 (ProjectIcons)

sublime-linter-projecticons

Change the gutter theme in the command palette with Sublime Linter: Choose Gutter Theme.

使用Sublime Linter在命令面板中更改装订线主题:选择装订线主题

结论 (Conclusion)

The Sublime Linter package is very flexible and has support for so many different languages. Take a look at the list of supported languages at the Sublime Text package control site.

Sublime Linter软件包非常灵活,并且支持许多不同的语言。 在Sublime Text程序包控制站点上查看受支持的语言列表。

There are also many more options available and be sure to look through the docs to see all that you can do!

还有许多其他选项可用,请确保仔细阅读文档以查看您可以做的所有事情!

翻译自: https://scotch.io/tutorials/how-to-catch-your-errors-in-sublime-text-3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值