Looking for a text editor with specific syntax highlighting features

developmentsoftwaresoftware-recommendationtext-editor

I'm a pc guy, but I have a programming student who's got a mac. We have been using TextMate, but there are a few features missing that I either can't find, or that are not available in TextMate.

In my beloved Notepad++ I have the following features:

  • vertical gridlines, that help you see how far indented you are
  • when putting your cursor next to a pair of brackets or inside an html tag, the matching bracket or tag will be highlighted, in the case of curly braces the aforementioned gridlines will even be highlighted (so if you have consistently indented code, you'll just have to scan down the highlighted, dotted line, and you'll find the matching bracket)
  • when highlighting a word (which is quick by double clicking on it) all other instances of that same word will be highlighted (where else did i use that function/variable? did i name it consistently?)
  • Commenting multiple lines of text by highlighting and hitting [strg]+[k]
  • Un-Commenting multiple lines of text by highlighting and hitting [strg]+[shift]+[k]
  • Indenting multiple lines of text by highlighting and hitting [strg]+[tab]
  • Un-Indenting multiple lines of text by highlighting and hitting [strg]+[shift]+[tab]
  • the ability to chose how to interpret the file (what language) textmate's interpretation is quite buggy… somethimes you'll open a file and it'll be all white even though it's clearly a .css file or so.
  • function completion, such as parameter hints, closing html tags automatically, and completing brackets, would also be helpful. I love hot notepad++ shows you when you type a variable what variable names you have already used in the document.

Textmate's handling of brackets and quotations rocks: it adds the matching pair for you, but wont advance the cursor, so if it's in your muscle memory to do them at the same time, it won't waste your time. and you can highlight a word and hit quotes or brackets, and it'll wrap the word in brackets. So those would be a bonus, but it's nothing I miss when using Notepad++, however the combination of lacking the above is frustrating.

enter image description here

Does anybody know a free program for Mac with these features?

And while you are at it, could you please point out how to activate and use these features?
For example I know TextMate has a way to indent, but the key combination it gives you makes no sense to me…

Thanks for any suggestions!

Best Answer

Sublime Text

There are some things worth paying for in life and a solid text editor is, in my opinion, one of them. If it's the tool you use every day, what's a few dollars to ensure that tool is high quality? For me, that editor worth paying for is Sublime Text. I'm still on 2, but 3 is a pretty stable beta and can be had for free for the time being. Both 2 and, when it leaves beta, 3 can be "evaluated" indefinitely if the price and paying for quality software really turns you off.

The upside to Sublime is it has a long and illustrious with a great community behind it. It has an awesome package management system in Package Control that lets you add a ton of features very quickly and easily.

To address your specific feature requests...

vertical gridlines, that help you see how far indented you are

Yes. Add:

"draw_indent_guides": true

to your preferences file.

bracket matching and tag matching when you're inside a tag

The BracketHighligher extension does this and more. There's a snazzy screen shot on its Package Control page that shows off all the ways it can highlight things out of the box.

You can find my Sublime preferences file here which has most of things you desire enabled in it already.

when highlighting a word (which is quick by double clicking on it) all other instances of that same word will be highlighted

Sublime calls this Multiple Selection. Select a word and then press Ctrl+Command+G or Cmd-D to select all occurrences of the word in the file. Typing will replace all occurrences simultaneously. You can do a lot more than that with Sublime. See the aforementioned page for other multiple selection ninja moves you can do.

Commenting multiple lines of text by highlighting and hitting [strg]+[k]

Highlight the block and press Command-/ to toggle comments on and off for the block. You can combine this with multiple selection mentioned above to comment out non-contiguous lines.

Un-Commenting multiple lines of text by highlighting and hitting [strg]+[shift]+[k]

It's Command-/ in Sublime to toggle comments which is easier to remember than an 'add comment' and a separate 'remove comment' action if you ask me. If you don't like the short cut you can reassign key bindings freely in Sublime to map the actions to a preferred combination.

Indenting multiple lines of text by highlighting and hitting [strg]+[tab]

That works exactly how you want: select the lines, TAB to indent, Shift-TAB to un-indent.

Un-Indenting multiple lines of text by highlighting and hitting [strg]+[shift]+[tab]

It's just Shift-TAB in Sublime.

the ability to chose how to interpret the file (what language)

You can override Sublime's language guess using the View > Syntax... menu. Pick the language you want it to be instead of the one Sublime guessed. Sublime's guessing is much better than TextMate's though IMO.

function completion, such as parameter hints, closing html tags automatically, and completing brackets, would also be helpful.

Absolutely -- they're called Snippets in Sublime's parlance. It ships with a bunch of defaults for some common languages like CSS, HTML, Ruby and Python that are useful. You can add your own snippets and you can find more language support and snippets in Package Control.