by Ayo Isaiah

通过Ayo Isaiah

何为JavaScript选择文本编辑器 (How to choose a text editor for JavaScript)

If you’re just learning to code, one of the first things you need to do, after deciding what to learn, is choose a text editor for writing code.

如果您只是在学习编码,那么在决定学习什么之后,需要做的第一件事就是选择一个用于编写代码的文本编辑器。

A text editor is a program that helps you write plain text (without any formatting) and save it to a file. A good example is the Notepad editor on Windows.

文本编辑器是一个程序,可以帮助您编写纯文本(不带任何格式)并将其保存到文件中。 Windows上的记事本编辑器就是一个很好的例子。

As you start your coding journey, you will quickly discover that the text editor is where you’ll spend most of your time — since the fundamental job of any programmer is to write and edit source code. This is why it is necessary to pick one that works for you and supports your learning effort.

在开始编码之旅时,您会很快发现文本编辑器将是您花费大部分时间的地方-因为任何程序员的基本工作都是编写和编辑源代码。 这就是为什么有必要选择一种适合您并支持您的学习努力的原因。

Not all text editors are great for programming, like the aforementioned Notepad, since it does nothing to ease or automate the editing of source code.

并非所有的文本编辑器都像上面提到的记事本一样适合编程,因为它无法简化或自动执行源代码的编辑。

There are some text editors that are designed specifically for writing and editing source code. These are called code editors. A code editor maybe a standalone program or built into an Integrated Development Environment (IDE).

有一些文本编辑器专门用于编写和编辑源代码。 这些被称为代码编辑器。 代码编辑器可以是独立程序,也可以内置在集成开发环境(IDE)中。

We also have code editors that live in the browser. CodePen, Web Maker, and Plunker are prominent examples. You may already be familiar with some of these web-based editors, since many online coding programs like freeCodeCamp recommend their use.

我们也有驻留在浏览器中的代码编辑器。 CodePen , Web Maker和Plunker是著名的例子。 您可能已经熟悉其中一些基于Web的编辑器,因为许多在线编码程序(如freeCodeCamp)都建议使用它们。

However, if you want to take your coding to the next level, you need to consider looking at a desktop editor which goes above and beyond the level of most web-based tools.

但是,如果您想使编码更上一层楼,则需要考虑使用一个桌面编辑器,该编辑器已经超出了大多数基于Web的工具的范围。

It’s easy to get overwhelmed when looking at the options out there as there are so many. Ask five people, and you’re likely to get five different answers.

鉴于那里的选择太多,很容易不知所措。 问五个人,您可能会得到五个不同的答案。

If you’re just starting out, you need to choose an editor that supports you as a beginner. Learning to code is already hard enough, so you can use all the help you can get.

如果您只是刚入门,则需要选择一个支持您作为初学者的编辑器。 学习编码已经足够困难,因此您可以使用所能获得的所有帮助。

The goal of this article is to help you decide what text editor to use when learning to code with a specific emphasis on programming in JavaScript.

本文的目的是帮助您决定在学习编码时特别使用JavaScript编程时使用哪种文本编辑器。

在代码编辑器中查找什么 (What to look for in a Code Editor)

All code editors can write text and save it to a file. Beyond that, the type of editor you choose is purely down to your personal preference. That said, there are a few things that your editor must have for it to be considered good enough for developing in JavaScript.

所有代码编辑器都可以编写文本并将其保存到文件中。 除此之外,您选择的编辑器类型完全取决于您的个人喜好。 就是说,您的编辑器必须具备一些条件,才能被认为足以使用JavaScript开发。

语法高亮 (Syntax Highlighting)

Literally all code editors support highlighting source code in different colors based on the language you’re working with. This improves readability, and helps you spot syntax errors much quicker.

从字面上看,所有代码编辑器都根据您使用的语言,以不同的颜色突出显示源代码。 这样可以提高可读性,并帮助您更快地发现语法错误。

自动完成 (Auto Completion)

Code auto completion is a feature offered by many code editors that helps to accelerate the editing process and reduce typos by completing the names of variables, keywords, classes, and methods within the scope of your program.

代码自动完成功能是许多代码编辑器提供的功能,可通过在程序范围内完成变量,关键字,类和方法的名称来帮助加快编辑过程并减少输入错误。

If you’re just starting out, I recommend turning off auto complete in your editor and typing everything out manually instead, so that you can memorize the syntax much quicker.

如果您只是刚入门,建议您在编辑器中关闭自动完成功能,然后手动输入所有内容,以便更快地记住语法。

However, once you’ve got a grip on all the basic keywords and built-in methods, I do not see much value in typing everything out by yourself. Auto complete becomes invaluable at this point.

但是,一旦掌握了所有基本关键字和内置方法,我便看不出自己键入所有内容的价值。 此时,自动完成功能变得非常重要。

A good editor should also provide support for the latest JavaScript features soon after they are released, and have a strong plugin ecosystem so you can get support for the most popular frameworks and libraries.

优秀的编辑者还应在JavaScript最新功能发布后立即为其提供支持,并具有强大的插件生态系统,以便您可以获得对最受欢迎的框架和库的支持。

With these considerations in mind, let’s look at a few options that you can use if you’re just getting started with JavaScript and web development in general.

考虑到这些注意事项,让我们看一下一般而言刚开始使用JavaScript和Web开发时可以使用的一些选项。

To make it easier for you to pick one, I have ranked them from most recommended to least recommended. This ranking is subjective so I encourage you to draw your own conclusions after trying each one out.

为了让您更轻松地选择一个,我将其从推荐程度最高推荐到了推荐程度最低。 该排名是主观的,因此我鼓励您在尝试每个结论后得出自己的结论。

All the editors listed here are cross-platform across Windows, macOS, and Linux so you don’t have to worry about compatibility with your favorite operating system.

此处列出的所有编辑器都是跨Windows,macOS和Linux的跨平台版本,因此您不必担心与自己喜欢的操作系统的兼容性。

Visual Studio代码-免费 (Visual Studio Code — Free)

Visual Studio Code (VS Code), not to be confused with Visual Studio, is the best text editor for JavaScript developers right now. Although it is relatively young compared to other popular editors, having just been released in 2015, it has improved in leaps and bounds over the years. So much so, in fact, that it was listed as the most popular text editor among web developers in the latest Stack Overflow survey.

不要将Visual Studio Code (VS Code)与Visual Studio混淆,它是目前JavaScript开发人员的最佳文本编辑器。 尽管与2015年刚发行的其他流行编辑器相比,它还比较年轻,但多年来却有了长足的进步。 事实上,在最新的Stack Overflow调查中 ,它被列为Web开发人员中最受欢迎的文本编辑器。

VS Code is more than just a basic text editor. Some people say it is closer to an IDE than a text editor, since it provides many features that you will typically find in an IDE.

VS Code不仅仅是一个基本的文本编辑器。 有人说它比文本编辑器更接近IDE,因为它提供了许多通常在IDE中可以找到的功能。

Some of its headline features include built-in debugging tools, intelligent code completion (IntelliSense), an integrated terminal, and native support for many common Git operations. As a beginner, you can leverage these features to produce working code at a much faster rate.

它的一些主要功能包括内置调试工具,智能代码完成( IntelliSense ),集成终端以及对许多常见Git操作的本机支持。 作为初学者,您可以利用这些功能以更快的速度生成工作代码。

Customizability is another area where Visual Studio Code shines. It supports thousands of plugins and themes which you can install to further enhance its capabilities.

可定制性是Visual Studio Code的另一个亮点。 它支持成千上万的插件和主题,您可以安装这些插件和主题以进一步增强其功能。

Sublime Text 3-$ 80 (Sublime Text 3 — $80)

Sublime Text 3 was the editor I first used when I was just learning to code, so I do have a soft spot for it. It’s a great editor that remains popular among web developers due to its simplicity and ease of use.

Sublime Text 3是我刚学习编码时首先使用的编辑器,因此我对此情有独钟。 由于它的简单性和易用性,它是一个出色的编辑器,在Web开发人员中仍然很受欢迎。

While its out of the box support for JavaScript is quite lame compared to VS Code, you can augment this by installing plugins. It’s also very fast and does not use a ton of memory — which is why I often recommend it for people whose computers have less than 4GB of RAM.

尽管与VS Code相比,它对JavaScript的开箱即用支持还很la脚,但是您可以通过安装插件来增强它。 它也非常快并且不占用大量内存,这就是为什么我经常向计算机内存少于4GB的人们推荐它的原因。

Although Sublime is pricey at $80 for a single user license, it can be downloaded and evaluated without cost. You only get a popup message from time to time reminding you to purchase a license for continued use.

尽管Sublime的单用户许可证价格为$ 80,但可以免费下载和评估。 您只会不时收到一条弹出消息,提醒您购买许可证以继续使用。

Atom —免费 (Atom — Free)

Atom was introduced in 2014 by GitHub as a free and open source alternative to proprietary tools like Sublime Text and Text Mate. Although it gained a fervent following, it never reached Sublime’s levels of popularity and has now been surpassed by VS Code which was released a year later.

GitHub在2014年推出了Atom,它是Sublime Text和Text Mate等专有工具的免费开源替代品。 尽管它获得了热烈的追捧,但它从未达到Sublime的流行程度,现在已被一年后发布的VS Code所超越。

That’s not to say Atom is a bad editor — far from it. It’s approachable for beginners and doesn’t require any configuration to get started. Just like VS Code, it is also extensible through plugins and supports many IDE-like features which can increase your speed and efficiency when writing code.

这并不是说Atom是一个糟糕的编辑器-远非如此。 对于初学者来说这是平易近人的,并且不需要任何配置即可上手。 与VS Code一样,它也可以通过插件扩展,并支持许多类似IDE的功能,可以提高编写代码时的速度和效率。

Vim —免费 (Vim — Free)

Vim is my current text editor of choice after various stints with other code editors. Although I use and love Vim, I would hesitate to recommend it for people who are just learning to code, because it has a completely different approach to editing text compared to other mainstream code editors. This means you have to invest time to learn how it works, which may distract you from actually learning to code.

在与其他代码编辑器进行各种交流之后, Vim是我当前选择的文本编辑器。 尽管我使用并喜欢Vim,但还是会推荐给刚学习编码的人,因为与其他主流代码编辑器相比,它具有完全不同的文本编辑方法。 这意味着您必须花费时间来学习它的工作原理,这可能使您无法真正学习代码。

If you’re busy learning to program, it’s better to use an interface you’re already familiar with so that you don’t get sidetracked from actual programming. Besides, Vim lacks many nice features that editors like VS Code or Atom provide by default. Although it is possible to add more functionality to Vim using plugins, the process for doing so is a bit more involved.

如果您正忙于学习编程,最好使用已经熟悉的界面,以免被实际编程所困扰。 此外,Vim缺少许多功能,如VS Code或Atom等编辑器默认提供的功能。 尽管可以使用插件向Vim添加更多功能,但是这样做的过程要复杂得多。

If you’ve already achieved a reasonable level of competency in the language you’re learning, and you’re interested in trying out Vim, you can take a leaf from how Yehuda Katz was able to transition to Vim without losing productivity and go from there.

如果您已经在所学习的语言上达到了合理的水平,并且对尝试使用Vim感兴趣,则可以从Yehuda Katz如何过渡到Vim的过程中受益匪浅,并从那里。

WebStorm — $ 129 /年 (WebStorm — $129/year)

WebStorm is another interesting option that many JavaScript developers swear by, although it’s a full-blown IDE and not just a text editor. It’s also the most expensive option that I know of, although you can get it for free alongside other JetBrains products if you are are a student.

WebStorm是许多JavaScript开发人员都希望使用的另一个有趣的选择,尽管它是功能完善的IDE,而不仅仅是文本编辑器。 这也是我所知道的最昂贵的选择,尽管如果您是学生,则可以与其他JetBrains产品一起免费获得它 。

I haven’t had any personal experience with WebStorm, but most reviewers are quick to praise its deep support for JavaScript and its ecosystem, as you might expect from a sophisticated IDE. On the flip side, it has a steeper learning curve than standalone text editors and lots of features that you don’t really need as a beginner.

我还没有任何WebStorm的个人经验,但是正如您可能从复杂的IDE中所期望的那样,大多数评论家很快就赞扬了它对JavaScript及其生态系统的深入支持。 另一方面,与独立的文本编辑器相比,它的学习曲线更陡峭,并且许多功能对于初学者来说都是您真正不需要的。

I think WebStorm could be a great tool to learn when you have a bit more experience, but I see no reason to start with it.

我认为WebStorm可能是一个学习的不错的工具,当您有更多的经验时,但我认为没有理由从此开始。

没有错误的选择 (There are no wrong choices)

Whichever of these editors you choose is great. All of them make good environments for writing JavaScript, so it’s really not a problem if you decide not go with the top pick in favor of something else.

您选择这些编辑器中的任何一个都很棒。 所有这些都为编写JavaScript提供了良好的环境,因此,如果您决定不选择首选工具来支持其他内容,这实际上不是问题。

What I would caution against is spending too much time learning complicated tools like Vim or WebStorm. As a beginner, you should focus more on programming itself — which is why I’ve listed Visual Studio Code, Sublime Text, and Atom as my top picks, as they’re all welcoming for newbies. I suggest you try out all three and pick the one you’re most comfortable with.

我要提醒的是,花太多时间学习复杂的工具,例如Vim或WebStorm。 作为一个初学者,您应该更多地专注于编程本身,这就是为什么我将Visual Studio Code,Sublime Text和Atom列为首选,因为它们都欢迎新手。 我建议您尝试所有这三个,然后选择最舒适的一个。

Thanks for reading! If you liked this, give it some love by pressing on the ? button! Feel free to check out my blog at freshman.tech for more beginner friendly content on web development and connect with me on Twitter.

谢谢阅读! 如果您喜欢这个,请按?来给它一些爱。 按钮! 请随时在f reshman.tech上查看我的博客,以获取有关Web开发的更多初学者友好内容,并在T witter上与我联系。

Have fun, and happy coding!

玩得开心,编码愉快!

翻译自: https://www.freecodecamp.org/news/how-to-choose-a-text-editor-for-javascript-ec75c2cee6b8/