Text Editors for Code Monkeys
If you're getting into programming or coding of any sort, you'll want to find a text editor that you like working with. A text editor is as blasé as it sounds: It's software that you use to read and write files whose sole content is plain ol' text. All coding language source files must be saved as plain text; another program takes that text file and turns it into something else. This also means that text editors can open and edit any text file.
This is in contrast to a word processor, which saves files in a binary file to store formatting data. A word processor must support the format the file uses. So, while any text editor can read a regular text file, such as an HTML file, not every word processor can read a Microsoft Word docx file.
This is what happens if you open a Microsoft Word docx file in a text editor.
One of the main reasons to invest in a text editor beyond a basic one like Notepad is to be able enhance the readability of the files and navigate through them more efficiently.
Common features of text editors
Basic text-formatting options
Text editors offer few formatting options that can be set by the user. Any option set will be applied to the text file as a whole, as well. Generally, the most formatting that can be done is which font to use, text size, tab type (actual tabs or just spaces) and spacing, and word wrapping.
Search and replace
A search function is, of course, a very useful thing. All text editors include at least a basic search feature. More feature-rich editors will allow you to search not only the file you're editing, but also files within a directory. Some editors will also all you to search by regular expressions, which is a kind of search language that is very powerful once you get the hang of it, allowing you to find text based on rules. For example, you can use a regular expression to find words that begin and end with a vowel.
Closely related to the search feature is the replace feature, used if you need to change instances of a search match. This can be within the file itself or across the matches found in a directory.
Syntax Highlighting
While very basic text editors usually lack this, others will have a feature that stylizes text files based on the coding language of the source file. Syntax highlighting is very useful to get a visual idea of what something is in a source file, and helps differentiate aspects of the code to help keep it from just looking like a blob of text. This is what stylizes the text, and while text editors have different ways of styling, they're usually consistent about what gets stylized.
A C source file before syntax highlighting…
… and after highlighting.
An example of where this comes in handy is specific types of variables used in the coding language, e.g., a string of text surrounded by quotes will often be stylized. If you happen to misplace a quote, then code that shouldn't be considered in that string of text will be highlighted, visually indicating something is wrong.
Programmer-friendly features
Text editors geared toward programmers will often have these features:
- Line numbers: As mundane as this option sounds, having line numbers shown is very handy when tracking down bugs and errors in source code. This feature is most helpful when it's shown along with the text rather than in a status bar.
- Auto-indent: Every time you create a new line, it will indent the cursor up to the last line's indentation.
- Auto-complete: It's similar to predictive text on touchscreen keyboards. If the text editor knows which coding language you're using, it will give suggestions when typing out words. You then choose the predicted text to complete the word.
- Brace matching: When highlighting a brace, which is usually a parenthesis, square bracket, or curly brace, it will highlight where the other one is. If you have a bunch of nesting, it's useful for figuring out which level of nesting a particular brace is in.
- Text folding: If the text editor finds a block of text that's within a logical group, like a programming function, the user can fold up the text so it doesn't take up room in the editor.
Recommended Text Editors
There are plenty of text editors out there, but here are some that we recommend. Unless noted otherwise, these are multiplatform and free.
Notepad++ is a feature-rich text-editor with many features out of the box and it certainly lives up to its name as being an "incremental" improvement over Notepad. One advantage it has over other text editors is that its syntax highlighting can be changed on the fly, regardless of what type of source file it is. Other text editors normally require the file to be saved, as syntax highlighting is based on the file's extension (Notepad++ will do this too).
Notepad++ also includes a plugin system (http://docs.notepad-plus-plus.org/index.php?title=Plugin_Central) to enhance features already there. These plugins are easily installed and removed with its built-in plugin manager.
The only downside is it's only available on Windows.
Atom is one of the new kids on the text-editor block. It's built with web-app development in mind, but it supports other programming languages as well. Like Notepad++, it has support for plug-in packages (https://atom.io/packages)(the screenshot featuring one) to enhance the feature set. It's also hackable, as its settings are stored in configuration files that you can edit.
One of its defining aspects is its integration support with GitHub, a source control service. If you make changes to the project, it will show up in the project explorer. Its main drawback is that, due to being built on top of Chromium (upon which Google Chrome is based), it's resource intensive. The install alone is 60MB and each file opens up a new tab, which, like Chrome, creates a new instance of itself in Task Manager.
GNU Emacs is a longstanding text editor with a large following of users. It's a feature-rich editor that can handle a variety of coding languages, create scripts to change the behavior of the program or appearance, and record macros. While you can skirt by using Emacs similarly as you would any text editor, its strength, if you could call it that, is that many commands are mapped to a keyboard command involving CTRL, ALT, and/or "Super" (usually the Windows key). This allows for efficient editing since it allows you to keep your hands on the keyboard (though you will have to memorize those commands before you become a seasoned pro).
Vim is a clone of another longstanding text editor, vi. Like Emacs, it has a large following of users and the two user bases often butt heads with each other over which is better. Vim was developed for programmers and is quite hackable, with editable configuration files. Its commands, unlike Emacs's however, are command line–driven rather than keyboard shortcut–based. This, unfortunately, makes Vim a bit daunting for newcomers, but once you've got the basics down, you can be quite efficient with it.
Vim is expandable by way of plugins as well, and there are plenty out there to choose from. Also, Vim or vi is on many Linux distributions, so you're usually not without it.
Text editors worth mentioning
GNU nano is something like the Notepad of Linux: a very basic text editor. As it's part of the GNU project, it's often included in Linux distributions. Like Emacs, commands are keyboard shortcut–based, but unlike Emacs, they're a lot easier to get a handle on. The bottom two rows display the commands and everything is CTRL-based.
Sublime Text bills itself as "The text editor you'll fall in love with," and a lot of people swear by it. It's feature-rich like the other recommended editors, is hackable, with plugin support, and with plenty of options and features some other text editors don't have by default. However, its $70 price tag is a tough pill to swallow when other free text editors have plenty of features and provide a pleasant coding experience.
If Notepad is like Paint and Sublime Text is like Photoshop, gedit is kind of like Paint.NET. It's not quite feature-rich, but it's a lightweight text editor with enough features (in particular, syntax highlighting for some languages) to get into coding. It's the default text editor of any Linux distribution using the GNOME desktop environment, but it's cross-platform as well.