Is there a command line editor that highlights the Stata syntax? [closed]
Asked Answered
A

5

5

My internet connection is extremely slow and therefore I execute batch files on the server without GUI, i.e. directly from the terminal. However, oftentimes I need to make a few changes in the code and a text editor highlighting Stata syntax would not hurt. Is there one?

Alesha answered 21/8, 2013 at 15:32 Comment(0)
G
4

Sublime Text editor has a package for Stata. If you're using mac you can find installation instructions here.

Greatuncle answered 21/8, 2013 at 15:41 Comment(9)
Is there a way to tie ST with Stata under Linux too?Asteria
@radek there's a version for Ubuntu: github.com/rhoconlinux/Stata-12-in-Sublime-3-under-UbuntuGreatuncle
That's fantastic. About time to get rid off default Stata's editor then =)Asteria
@radek Perhaps that's just a joke, but the answer is still no. Stata's own editor is not a full-blown text editor and never will be but it is (1) closely integrated with Stata, naturally (2) there for people (probably the majority of Stata users) who don't regularly use any text editor. (I regularly encounter Windows users who don't even know what a text editor is, let alone which is installed on their machine. I am happy to assume that people using other OS are typically different.)Constriction
@NickCox I've noticed that text editor allegiances can almost cause wars in the IT world and it's not my intention to start one here. I've recently moved from Windows to Linux based Stata and transition from Notepad++ to default editor has been extremely painful to me. Perhaps it's just me or my habits/preferences but I find it limiting and pain to work with (hence my quest for a better alternatives).Asteria
As for the majority of users you point to - I totally agree. But lack of knowledge is not a reason to defend status quo, rather - for more education. I've personally converted few of them and they never looked back to defaults. And it probably suggests that we would all extremely benefit from improving the editor that comes bundled with the software ;)Asteria
Quite so. Everyone can agree that a versatile editor you know is better than a more limited editor which is unfamiliar.Constriction
StataCorp do make improvements to the editor in virtually every release. But whenever this is discussed (e.g. at users' meetings) it comes down to (1) experienced users, who often also program, who already have a favourite text editor from outside Stata (2) new users for whom Stata's editor is fine (3) others, who tend not to be vocal.Constriction
I've taught a reasonable amount of complete beginners to write do-files in Stata, and have been very satisfied with the interface since Stata 11 (which introduced syntax coloring on Mac, if memory serves). It's a good one, the new users are right in their assessment. The only annoyance is that Ctrl-D on Windows (execute selection) is Cmmd-Shift-D on Mac, and that Ctrl-Shift-D on Windows does something different. This is a frequent source of issues in classes with both Macs and Windows machines.Squeamish
S
3

As linked by Maarten Buis, Nick Cox's list is the reference. It's a cool list, but it's badly outdated and therefore misses out the best parts of Stata support on Mac OS X. Here are some additions that also allude to the other answers.

Mac

TextMate has two Stata bundles, the Beatty bundle and the more recent Schumm bundle that uses a smarter approach to Stata syntax. (Note: not sure whether the Beatty bundle works under Stata 13; the Schumm bundle, which is the one you get through TextMate's bundle settings, does.)

Two other editors, Chocolat and Sublime Text, support TextMate bundles or ports of TextMate bundles. Phil Schumm's Stata bundle for TextMate is the most advanced and up-to-date solution that I know of, so I'd recommend that if you need an external editor.

TextWrangler also supports Stata through its own plugin system. I guess that BBEdit might therefore support it too, probably through slightly more awkward AppleScript calls. The only reason I see to use these instead of TextMate is if you are running an old system and/or are using these editors already.

If you need more alternatives, check out websites like Alternative To, I Use This, MacUpdate or VersionTracker for a larger choice of options. You'll find out that SubEthaEdit and Smultron (and probably its deceased fork, Fraise) support Stata, for instance.

tl;dr On Mac OS X, use TextMate with the Schumm bundle, and you will like it. (No idea if you can create GitHub issues through email, though!)

Win

Notepad++ has support, and there are mentions on Statalist of PFE, UltraEdit and WinEdt also having support. My guess is that you will find it more useful to get Sublime Text and use its Stata bundle port, unless again you are already using these editors.

tl;dr On both Mac OS X and Windows, Sublime Text with the Stata TextMate bundle port seem to work well.


As mentioned in another answer, Vim also offers support, and Emacs has an ado major mode, plus some additional functions through ESS (Emacs Speaks Statistics). Finally, if you are looking a Java cross-platform solution (but why would you?), jEdit supports Stata syntax.

If you want support for Stata colored syntax everywhere (e.g. on GitHub), you'll need to write a lexer for Stata and submit it to Pygments. I've asked a question about that. It does not look very difficult if you know enough Python (which I do not and regret).

HTH

Added: links, sections.

Squeamish answered 21/8, 2013 at 18:45 Comment(1)
"badly outdated" is entirely fair comment. Life is short, and there are many things to do. That document is something I am no longer able or even inclined to update; indeed the task of documenting all possible text editors now seems too much like hard work. Caveat lector.Constriction
R
2

Unsurprisingly, Vim supports syntax highlighting for Stata out of the box. See http://www.vim.org/scripts/script.php?script_id=440 and this blog post: http://www.enoriver.net/stata/2010/02/26/i-switched-to-vim/

Renee answered 21/8, 2013 at 15:47 Comment(2)
FWIW, Vim has been my main text editor for many years. It's perhaps important to know that its syntax highlighting does not mean highlighting all Stata command names as such. That would entail maintaining a list of all user-written commands, or minimally those that an individual user might include in their code, a Herculean (Sisyphean?) endeavour. Syntax highlighting can be extremely useful even with that self-denying ordinance.Constriction
Changed the blog post link; original is broken.Constriction
I
1

Similar to the other folks, my recommendations are Sublime Text and TextMate. They're my favorite editors on Windows and Mac, respectively. If you're a Mac user, I recommend TextMate (It's free, but Sublime Text is not).

You asked for a text editor, but if you also use any HTML editor, you can use Statax useful. (Here is the link to Statax, if it interests you).

Inbeing answered 15/2, 2016 at 18:7 Comment(0)
A
1

This question was asked years ago, but I would like to add another option that is probably already known to more experienced Stata users. However, this may not be the case for new programmers who end up here, perhaps through a search engine, looking to find more information on the topic.

Visual Studio Code is a streamlined code editor, which offers a very flexible environment for programming. Once installed, one can obtain the necessary add-on package for Stata syntax highlighting from the Visual Studio Marketplace. It is regularly updated and the user can expand its functionality using extensions. As such, if someone is programming in more than one language, s/he can keep everything under one roof.

This solution addresses the OP's need to edit files remotely through its built-in Git support. Git is now pretty much the standard in version control. The idea behind it is that one does the work locally and then syncs the copy of the repository with the copy on the server.

Although this is not a command-line solution, i think it provides a great cross-platform development environment. And Git itself has proven to be very fast and reliable.

Agora answered 6/5, 2018 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.