Text Editor with Scripting…for Linux

一世执手 提交于 2019-12-21 17:11:40

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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




回答8:


Try Emacs, either XEmacs or GNU Emacs.




回答9:


I use gedit. You can write plugins in Python.




回答10:


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.




回答11:


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.




回答12:


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.




回答13:


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.




回答14:


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.



来源:https://stackoverflow.com/questions/504943/text-editor-with-scripting-for-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!