What's a good text editor that you can adapt to any IF language?

My games are Twine, but I never used Twine itself, preferring text files compiled to Twine with something like twee2. So I write in a text editor, mainly gedit* so far.

I would like to know if you have any recommendations for a text editor (or an IDE) that can be easily adapted to a custom language. No editor has support for Harlowe or Sugarcube (or, even worse, the custom pseudocode that I’m using for my stuff), so I would like an editor where you can easily add that support. The important word being “easily”.

Features that I’d like to have:

  • Syntax highlight
  • Snippets
  • Folding complete passages (that is, being able to configure “::” as the point to fold stuff)
  • Navigating passages the way editors let you navigate functions, classes, etc. (that is, being able to configure “::” as a thing to be indexed)
  • Other nice stuff? Macros. A nice, minimal interface (I’m not going to use 99.99% of the dev functions after all). Selecting text and surrounding it with something (so you can write something and then put it inside a hook or whatever).

I’d be really grateful for any suggestion.

*For the record, I’ve configured more or less easily both syntax highlight and snippets for gedit. I also use Brackets, but not much because configuring custom syntax highlight seems like a nightmare.

1 Like

I recently switched to VS Code and like it very much. It’s open source and there are all sorts of plug-ins available.

2 Likes

John Ayliff has a Twine/SugarCube language definition for Notepad++

https://www.johnayliff.com/works.html

3 Likes

I find VS Code great, too.

After a quick search, I’ve just found there exists a Twee2 extension for VS Code. I don’t know if it’s good, though.

Adding support for a simple language in VS Code is not that hard, but it takes some time and you have to know a bit of regex. It took me several days, or maybe more than a week, to write an Inform 6 extension (but I was reading the DM4 in parallel, so a lot of time went into reading.)

1 Like

That’s excellent!

I’ve just looked the VS Code site and it literally mentions implementing a language server to fully support a new language… But if there’s a simpler way I can probably get my head around it, I know my little bit of regex.

No need for a language server! Adding syntax highlighting only requires writing a JSON file.

A language server is mainly used to analyse your code while you’re writing it, so that it can show your errors, display the description of functions when you hover them, suggest intelligent autocompletion… Things like that.

You might want to check out TextAdept. It’s pretty solid, has all the features you want (I think), and it’s very easy to add lexers for new languages and customize in pretty much any way you can think of with a bit of Lua. It comes with lexers for tons of languages, so you can take an existing one that’s similar to the language you need and modify it pretty easily.

The author is also super helpful, if you get stuck or need help.

It’s more on the minimal (text editor) end of the spectrum though, definitely not an IDE.

1 Like

Interesting! Even having zero knowledge of Lua Textadept seems to be easier to customize than most other editors. I’ll sure take a look at it.

vim, of course. Well, neovim has more features right now.
With these plugins:

Macro and syntax highlights are in by default, and the interface is so minimal you’ll have to read the help file (type :h)

Vim’s a good suggestion too. Can be difficult to get used to modal editing coming from something like gedit, though. That reminds me, regarding TextAdept:

  • It is modeless and uses familiar keyboard shortcuts (like basically any other editor or text input thing besides Vim or Emacs).

  • Code folding, snippets and macros are built-in.

  • Autocomplete and inline help are built-in, but don’t pop up automatically. Use ctrl-space for autocomplete, ctrl-h for inline help.

  • Ctags support is built in (for autocomplete, inline help, jump-to-definition).

  • You’re on your own for Twee syntax highlighting, most likely. Intersection between the two user bases is probably close to zero.

Actually, TextAdept comes with both a GUI version (GTK2/Scintilla) and a terminal version. The terminal version is more vim-ish, with mark-based selection and some less obvious keyboard shortcuts. But the GUI version is quite good.

1 Like

I’ve been using sublime text. It’s done what I’ve needed it to do, is lightweight, and has syntax plug-ins for Twee.

I had Sublime already installed, tried to install the Twee syntax, but it won’t work whatever I do…

I wish I knew enough about the program to tell you how to fix it.

After much testing, I’ve finally settled on a slightly convoluted setup but it doesn’t require much tech knowledge. In case it can be of use…

My text editor is Visual Studio Code with a number of extensions.

  • The native snippet function is simple to configure and lets you insert any template with just the tab key.
  • For a passage index, I found a bookmark panel extension: I define each passage name as a bookmark, and the list appears in the side panel.
  • There is a Twee format extension that provides some basic syntax highlight for Twee. I was utterly incapable of extending it, but I found a highlighter extension where you define certain regexes and it highlights the matches with whatever custom formats you define, way simpler.
1 Like