views:

1116

answers:

14

For a while now, I have been using UltraEdit on my Windows box. The ability to write scripts with a familiar language (JavaScript) has proved to be extremely useful. The only problem is that I cannot use it on my Linux box at work. Is there a comparable text editor that runs on Linux and has an integrated scripting engine?

Not breaking the bank and being cross-platform would be great.

EDIT:While recordable macros are great, I use the scripting engine much more.

+2  A: 

It's kind of cliche, but emacs. Or am I misunderstanding what UE's script engine is?

mabwi
+2  A: 

Try Emacs, either XEmacs or GNU Emacs.

starblue
+4  A: 

emacs is free and has its own embedded lisp dialect which can be used to write nearly anything, including light scripting as well as mail user agents and IRC clients ;-)

There's a bit of a learning curve, but my experience with emacs has been very positive. I don't like modal interfaces too much, and no other editor puts the navigation shortcuts right under your fingers.

Jonas Kölker
I like to argue with emacs users about this. Emacs *is* modal. There is the ctrl mode, shift mode, meta mode. The only difference is that in vi, mode change is on different keys (esc and i) instead of the same key.
Zan Lynx
The other difference is that emacs leaves "ctrl mode" when you release ctrl, not when you hit another key.And I would actually disagree. The shortcut "C-c ." would then seem to cross modes, which sounds wrong. In any case it comes down to definitions, which can't be correct, only (un)?intuitive.
Jonas Kölker
Good grief. Emacs isn't modal. You're just playing games with semantics to confuse rather than educate. You are always in text editing mode unless you are actively entering a command. Or, if you really want to get down to brass tacks, you are always in command mode but some commands do nothing more than insert a character.
Bryan Oakley
+4  A: 

I use jEdit, that is a great editor and allows to be scripted with beanshell. As it is written in Java it runs well under Windows and Linux.

Simon Groenewolt mentioned, that a plugin (JavascriptShell) exists, that allows you to write Macros and Scripts also in Javascript, not only in Beanshell.

Mnementh
I've jEdit for a long time, whenever I need a text editor that has coding support but that is not a full IDE. Maybe the JavascriptScriptEnginePlugin even supports scripting it in javascript?
Simon Groenewolt
You're right, the description of the plugin says: 'The JavaScriptShell plugin adds to jEdit a new script handler so you can write macros and startup scripts in JavaScript. It also adds JavaScript shell to the console interface provided by the Console Plugin.' So scripting in Javascript is possible.
Mnementh
+3  A: 

If you don't need really complex scripting, vim/gvim allows you to record a keystroke sequence and play it back. And you can give a repeat count on the playback, so you can record an operation on one line, then repeat it for the next 10,000 lines in one step.

Paul Tomblin
I'm a big fan of vim - thanks for suggesting it here :)
inkedmn
+28  A: 

All of the major open-source editors and most of the others hava a scripting facility of some description - some (Emacs in particular) are famous for it. The only ones that don't tend to be very lightweight ones like pico.

vim has a native scripting language and can also be built with embedded Python, Tcl or Perl interepreters that can operate on selections, buffers etc through the plugin mechanism. Emacs is all about scripting - it's has a LISP interpreter built right into the core of the system and most of the editor is written in LISP. There is a running joke about emacs describing it as a LISP interpreter that someone just happened to use to write a text editor.

Vim's user interface is descended from vi, which is somewhat quirky but very powerful once you get used to it. It also does recorded keyboard macros particularly well and has a very nice regular expression search/replace facility.

Emacs is regarded as a bit of a baroque monstrosity and is very large and complex. However, its scripting capability is second to none and there is an enormous variety of macro packages that do many things. It has a very loyal following of people who swear by it; once you've gotten over the learning curve (there is an enormous body of resources on the web to help with this) it's a very powerful system indeed. You can customise emacs into a whole IDE and there are people around who claim to spend the majority of their tube time in it.

Both of these editors can work in text mode or with a GUI and are highly portable, running on a wide variety of platforms. They are both open-source.

I've used both; I used to use XEmacs (a major code-fork of emacs that goes back a number of years) back in the 1990s but went to vim later on. I even use vim on Windows.

If you find the user interface of Vim or Emacs a bit too much, there are a variety of other text editors available, many of which offer scripting. Examples of these are SciTE, which has a built in Lua interpreter, NEdit, which has a homebrew macro language of its own or GEdit, which is substantially written in Python (which can also be used for scripting it) and has a plugin API.

EDIT: Outside of a few specific projects (e.g. Mozilla) Javascript never got much traction as a stand-alone or embedded scripting language in open-source circles. Historically there wasn't a popular open-source Javascript interpreter that got widespread acceptance in the way that Python or Tcl/Tk did. Javascript is more widely used in closed source systems such as UltraEdit or InDesign (to name a couple) whereas other languages were more popular on open-source projects.

None of the open-source text editors that I am aware of feature javascript as an option for a scripting language (feel free to step in and comment or edit this if you know of one). You will probably have to move off Javascript to another language such as Python or LISP. However, now that QT comes with a Javascript interpreter (QTScript) you may find some of the KDE-based ones offering this as a scripting option, but I am not specifically aware of any off the top of my head.

ConcernedOfTunbridgeWells
Komodo Edit, as suggested by Ionut G. Stan. It's not OSS though.
geowa4
Love how you covered everything. +1.
Ray Hidayat
+4  A: 

Vim is omnipresent and vimscript is really easy and text-editing oriented: http://vimdoc.sourceforge.net/htmldoc/usr_41.html

That comes by default. You can also use Python, Ruby, Perl, Scheme... but that requires compiling.

Python might be a good choice, since omnicomplete requires it. I run a separate binary for omnicomplete anyway since I like the ultra-lean vim for other usage, check here: http://vim.wikia.com/wiki/Compile_a_separate_copy_of_Vim_for_Python_coding

Honestly I haven't used python to script vim per se. I usually code, python or not, with vanilla vim and no auto-complete. I do however call python and any other command from vim to process my files line by line, might reply with more about that if you are interested, but that doesn't require to compile anything, works as is.

EDIT: if you want a point-and-click editor, you can run Cream on gVim http://cream.sourceforge.net/download.html I still think that vim takes little time to get used to and is VERY worth learning, more so considering you can use your basic vi knowledge to connect to a server via SSH no problem, and it's installed in any *nix. I like knowledge I can reuse, saves me time and trouble long term.

nachik
+2  A: 

I use gedit. You can write plugins in Python.

ggambett
+3  A: 

Wow, I really don't want to start a holy war here, but all these Emacs recommendations are kind of missing the point. Emacs is very powerful, but let's be honest. It doesn't have a learning curve so much as a learning WALL. Going from a point-and-click IDE style editor like UltraEdit is going to be a huge culture shock.

And honestly, when someone says they like to write scripts in javascript, and are looking for something similar in Linux, the first thing you say is "learn LISP"?!

This is why people think Linux is hard to use


I'm going to go in another direction entirely and suggest Aptana Studio

It has built-in highlighting and code-completion for a variety of languages, and supports scripting in javascript with Eclipse Monkey. It is based on Eclipse, and therefore runs on java hence multiplatform. And it is available for free.

Adam Lassek
thanks, but the only problem is how long it takes Aptana/Eclipse to load.
geowa4
+2  A: 

Komodo Edit is made on top of Mozilla's XUL Runner. It offers possibilities for extending it thorough either extensions (like Firefox) or macros, snippets, commands. You may write these snippets in either JavaScript or Python, which is nice, but you still have to know the API in order to do something useful.

Being built with Mozilla technology it runs on Linux too.

Ionuț G. Stan
+1  A: 

The traditional way for doing scripted text editing in Linux is to use the facilities that have (almost) always been available in *nixes: sed, awk, grep, things of that nature. Sure, they maybe don't appear to be as "handy" as one might find an integrated Javascript engine, but they are very mature and work well. If this scripting language MUST be inside the editor, Emacs is probably a good one here too.

You could use an "integrated" type solution to solve the problem, as lots of others have mentioned, but IMHO the commandline is more powerful in this regard.

sheepsimulator
A: 

SciTE can be scripted with Lua and is a good, simple editor which behaves much the same way if you're switching between Linux and Windows every day.

Pete Kirkham
A: 

I don't know what you're using the scripting capabilities in your editor for, but you may want to consider automating those tasks using Linux command-line tools such as sed or awk.

Ferruccio
+2  A: 

It looks like Komodo Edit, SciTE, and Eclipse Monkey are the winners. Komodo Edit seems to be most similar to Ultra Edit. SciTE is something I've used before, and Lua is not that difficult; SciTE's API though does not seem as extensive as Komodo Edit's API. Eclipse Monkey is something I am definitely going to use, but it requires Eclipse, which is definitely not a text editor.

EDIT: UltraEdit is coming out for Mac and Linux Soon.

geowa4