Text Editor: Improvements

Now the auto close option is also available as a user pref on the Editing tab. Since I’d like to add more functionalities, I created a new panel to group them.


This is great! The better the native text editor gets the easier it is to get people into trying python scripting. Looking forward to seeing where you take this project :smiley:

1 Like

It would be nice to improve Toggle Comments, right now it just puts a # at the beginning of the line, while it should keep the current indentation level. And the indentation itself can also be improved, I would like to use Cmd+[ and Cmd+] for this, but the current implementation of the text.indent does not allow this.

1 Like

I would need to understand a bit better how that works, but I can try improving it as well! At the moment I’m trying to get a better indent when pressing enter inside empty brackets and also the surround of selected text shown in the gif above.

1 Like

In fact, what I’m talking about is much simpler than what you’re already doing.

The TEXT_OT_indent is designed to work with Tab key, so if there is no selected text, then it inserts a tab:

  if (txt_has_sel(text)) {
    txt_order_cursors(text, false);
  else {
    txt_add_char(text, '\t');

It probably also has something to do with TEXT_OT_indent_or_autocomplete.

You can just add ot->invoke to know which key the operator is called with and make an exception for Tab, well, or some smarter way. I mean that any other key could indent/un-indent regardless of whether there is a selection or not.

For comments, it’s a little more complicated, you need to look at txt_select_prefix and txt_select_unprefix. But I think it should be simple.

1 Like

There are plenty of very basic things missing from the Text Editor:

Etc. but since the Text Editor is officially in maintenance mode, again, ensure the greenlight of the module owner before you invest in implementing a new feature or a fix in the Text Editor.


Those are some awesome changes, I’ll try to get in touch with @ideasman42 and improve what I can.


Imagine if you got rid of Blender’s existing text editor engine, and replaced it with an embedded copy of Emacs. Then you would have instant access to a customization/automation engine that has been refined and extended for over half a century.


I’ve just sent this patch. It’s still to be revised though.


This patch is now up as well.


This is great! Thanks so much for improving the text editor. I couldn’t tell if this was included or not from the gif, but the one thing I would love to have with Auto Close is the ability to put parentheses or quote marks around the selected text instead of the default behavior of replacing the text with a quote mark.

1 Like

Yep, I was taking a look at this one, but I’m still grasping the ideas behind the code. That’s why I’m doing the “easier” ones first to get more comfortable with it!


Great to see the text editor getting some love! The one feature that I miss is the ability to copy and paste a whole line without selecting the text


I tried it out and now we’ve got this:

I’ve just sent this patch to be reviewed.


Amazing, thank you!!!


Was wondering if blender will add support for right-to-left support for languages such as arabic and hebrew?

Unfortunately that’s a question I won’t be able to answer. That’s still a bit far from what I’m able to make at the moment.

That is on my long "to do” list of text output improvements, hoping to get to right-to-left ordering and font shaping within a year or so. Depends on how much I can get approved per release.

This would just be for display of RTL and proper shaping of complex languages. It would be a much different and separate step to improve entry of RLT though, and one that would have to come later. For an illustration of the complexities of that, try selecting portions of the following: 123اَلْعَرَبِيَّةُ and know that your browser is doing it correctly.

I’d like to start working on this one, but I’m a bit lost as to where to add this code. Do you all have any pointers?

You will have to ask @ideasman42.

1 Like