DEV Community

loading...
Cover image for Why TextMate 2 is My Favorite Code Editor for Mac (Part II)

Why TextMate 2 is My Favorite Code Editor for Mac (Part II)

davidmles profile image David Morales Originally published at davidmles.Medium Updated on ・5 min read

After seeing the file browser, configuration and memory consumption of the most popular code editors for Mac, in this second part I’m going to compare code detection and syntax highlighting for Ruby and Markdown.

Rails file detection

For the editor to highlight syntax, it must first correctly detect the file we open. I haven’t always come across this case, and now I’m going to check it out.

Selecting the file type in TextMate 2

When you open a Ruby on Rails controller in TextMate 2, it is detected as a Ruby file. This means that the framework’s expressions are not highlighted, such as require_dependency. Changing the file type to Ruby on Rails solves this problem.

A Ruby on Rails file in TextMate 2

But what happens when we close the file and reopen it? TextMate 2 now assigns the Ruby on Rails type not only to this file but to the other .rb files as well, until we change it again. In this case, there will be no difference between the two modes when opening a Ruby file, but it does help when opening a controller, model, etc., in Ruby on Rails mode.

Sublime Text 3 also detects the file as a Ruby type. Switching to Ruby on Rails solves the problem. But when you close and re-open the file, it does not remember the type manually selected. This forces us to select the type manually each time or to configure it explicitly.

Selecting the file type in Sublime Text 3

Atom has the opposite behavior. Somehow it knows that it’s a Rails project, and it opens all the .rb files in this mode. Even if you select Ruby and re-open the file, it still opens as Ruby on Rails. I imagine it can be customized in the settings.

Selecting the file type in Atom

Unfortunately, Visual Studio Code does not have the Ruby on Rails file type, so all files must be opened in plain Ruby mode. Doing a quick search, I couldn’t find any extension to add the Rails file type.

Selecting the file type in Visual Studio Code

In Brackets the same thing happens: there is only a file type for Ruby files. I couldn’t find an extension to add one for Rails either.

Selecting the file type in Brackets

Color scheme

The color scheme of the code is very personal. In my case, I have worked for a few years with the TextMate 2 Twilight scheme. In this editor, you can find many other themes and install them.

Twilight color scheme in TextMate 2

How easy is it to install Twilight in other editors?

In Sublime Text 3 it is as simple as installing it from the package control. In the color scheme selector, it appears as Twilight+

Selecting the Twilight+ color scheme in Sublime Text 3

In Atom you search for the theme from the preferences, and then in the theme options, it appears as Twilight in the syntax theme.

Selecting the Twilight+ color scheme in Atom

After a search in Visual Studio Code, I also found this theme. After the installation, it appears in the color theme selector as Twilight.

Selecting the Twilight+ color scheme in Visual Studio Code

Finally, in Brackets I have also found the theme Twilight and several more related, but after trying them all, none is the same as the original.

Twilight color scheme in Brackets

Embedded Ruby code highlighting

An essential part of web development with Ruby on Rails are templates. Within these, it is convenient that HTML and embedded Ruby code can be quickly distinguished.

In TextMate 2, by default, the Ruby code has a highlighted background, so although it may not look particularly attractive, it is swift to see.

ERB highlighting in TextMate 2

I noticed that the other editors don’t offer this highlighting out of the box, but let’s see what happens after changing the color scheme to Twilight.

Sublime Text 3 does highlight the embedded Ruby code, although more subtly, detecting the file as HTML (Rails).

ERB highlighting in Sublime Text 3

Atom detects the file as HTML (Ruby - ERB), but it does not highlight the Ruby code. Also, the file tab looks weird.

An ERB file in Atom

Visual Studio Code detects the file as html.erb, and it does not highlight the Ruby code either.

An ERB file in Visual Studio Code

Finally, Brackets detects it as Embedded Ruby, but it does not highlight the embedded Ruby code.

An ERB file in Brackets

Markdown

Markdown has become a widely used text format for documentation files within the source code, such as Readme files.

I’m going to open the Readme file of the project and see how each editor shows it by default.

In TextMate 2 the text has syntax highlighting, previewing some things like the size of titles. It is also easy to navigate them from the bottom of the editor.

Markdown format in TextMate 2

There is no preview in Sublime Text 3, and you can also navigate easily using the Goto Symbol feature.

Markdown format in Sublime Text 3

Atom is the same case, but its feature to navigate through symbols fades out the contents of the file. It’s another way to do it; I don’t like it.

Navigating symbols in Atom

Visual Studio Code does not preview the size of titles either, and its Go to Symbol in File function is very similar to Sublime Text 3.

Markdown format in Visual Studio Code

In the case of Brackets, there is no preview. And although I searched for a “go to symbol” feature, I haven’t found any.

Markdown format in Brackets

In the next and last article of this series I write about Project search and Open quickly features.

Discussion (0)

Forem Open with the Forem app