Essential Text Editor add-ons for coders

This thread is for sharing add-ons which will modernize, expand and ease coding in the Blender Text Editor, as Blender devs no not endorse any further development of it.

ENHANCING THE TEXT EDITOR:

THE CODE EDITOR:
By Jerryno, Iceythe/Kaio
Minimap, text tabs, whitespace markers and indent guides:
CodeEditor2
Download: https://github.com/K-410/blender-scripts/blob/master/2.8/code_editor.py

*TEXTENSION
By Kaio
https://github.com/K-410/textension

INTELLISENSE/AUTO COMPLETE:
By Mackraken and Tintwotin
Intellisense
Download: https://github.com/tin2tin/Intellisense_for_Blender_Text_Editor

HIGHLIGHT OCCURRENCES:
By Iceythe/Kaio

Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_highlight_occurrences.py

EXPAND TO BRACKETS:
By Iceythe/Kaio

Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_expand_to_brackets.py

TEXT COPY:
By Iceythe/Kaio

Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_copy2.py

TEXT INSERT:
By Iceythe/Kaio

Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_insert2.py

MOVE TOGGLE:
By Iceythe/Kaio
Makes Home key toggle between line begin and first indent.
Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_move_toggle.py

TOGGLE COMMENT:
By Iceythe/Kaio
Toggles comments on/off.
Download: https://github.com/K-410/blender-scripts/blob/master/2.8/text_toggle_comment.py

HOTSTRING REPLACEMENT
By Mackraken

Download: https://blenderartists.org/t/text-replacement-for-blenders-text-editor-hotstrings/1188692

DEVTOOLS:
By Pullusb
image
Download: https://github.com/Pullusb/devTools

CODE NAVIGATOR
By Greg Zaal - update to 2.80 by Tintwotin


Download:
https://github.com/tin2tin/Code_Navigator/tree/master

TEXT MARKERS:
By Samy Tichadou (tonton) - update to 2.80 by Tintwotin
image
Download: https://github.com/tin2tin/TextMarker-blender-addon

CONTENTS VIEWER:
By Alfonso Serra, Tintwotin
image
Download: https://github.com/tin2tin/ContentsViewer

TRIM WHITESPACE, CHANGE CASE AND SPLIT & JOIN LINES:
By Tintwotin
Whitespace
Download: https://github.com/tin2tin/Trim-Whitespace-Change-Case-and-Split-Join-Lines/blob/master/Trim-Whitespace-Change-Case-and-Split-Join-Lines.py

CODESTYLE CHECKER:
By Tintwotin
Codestyle
Download and instructions:
[https://github.com/tin2tin/Python_Stylechecker_for_Blender]

HORIZONTAL FIND AND REPLACE:
By Tintwotin
image
https://github.com/tin2tin/Horizontal-Find-Replace

ENHANCING THE CONSOLE

PRINT LOGS IN PYTHON CONSOLE:
By Tamask
9adba6487f57f49292e30fca77a6ba69c33b21e8_2_1035x448
Download: https://gist.github.com/tamask/0593436d044bfedb21081e3d2d802833

ADVANCED RUN SCRIPT IN CONSOLE:
By Iceytea/Kaio
Execute a text block and catch its output (prints and errors) in Blender’s interactive console.
Download: https://github.com/K-410/blender-scripts/blob/master/2.8/run_in_console.py

RUN SCRIPT IN CONSOLE:
By CoDEmanX


Download: https://gist.github.com/tin2tin/a48ab242db6f6d9ce6fa36c85464bc1d

DEBUG MODE:
By Tintwotin
For a much more verbose output in the Info Editor, an(unexposed) operator is added to the Info Editor menus in this add-on:
image
https://github.com/tin2tin/Debug-Mode-for-Info-Editor

UTILITIES FOR BLENDER ADD-ON CODING

SNIPPETS LIBRARY:
By Pullusb


Download: https://github.com/Pullusb/snippetsLibrary

SEARCH ONLINE:
By Tintwotin
In: API Reference, Python Reference, Blender Stack Exchange, Blender Source Code and Github


Download: https://github.com/tin2tin/Search-API-Reference

ADDON TEMPLATE GENERATOR:
By chichige-bobo, tintwotin
generator6
Download: https://github.com/tin2tin/BlenderPython/blob/master/AddonTemplateGenerator.py

UPDATE CODE TO 2.8+ CHECK:
By nBurn(and UI by Tintwotin)
A script for checking functions which needs to be updated to 2.80 api with this add-on : https://github.com/tin2tin/Update_Check_2.80
UpdateScriptTo280Check2

INCREMENTAL AUTOSAVE:

Download: https://www.mediafire.com/file/z59wvvowsq35q2s/auto_blend_save.py/file

INCREMANTAL AUTOSAVE:

Additional Text Editor Add-ons(afaik not ported to 2.80):
https://github.com/pistiwique/pistiwique_pie_text_editor
https://code-autocomplete-manual.readthedocs.io/en/latest/index.html#
https://github.com/natecraddock/AddonDevelopmentTool
https://blenderartists.org/t/text-editor-improvements/480723
https://learningblender3dsoftware.blogspot.com/2012/12/ui-customization-enhancing-text-editor-header.html
https://learningblender3dsoftware.blogspot.com/2014/03/debugging-tools-wip.html

Ideas:

EXTERNAL IDE SOLUTIONS:

SCRIPTING LIVE LINK:
https://blenderartists.org/t/scripting-live-link/1182392

BLENDER MODULE FOR EXTERNAL EDITORS:
https://github.com/nutti/fake-bpy-module

EMACS:
https://github.com/ldo/edit_external_for_blender

VSCODE:
https://marketplace.visualstudio.com/items?itemName=JacquesLucke.blender-development
https://b3d.interplanety.org/en/using-microsoft-visual-studio-code-as-external-ide-for-writing-blender-scripts-add-ons/

PyCharm:
https://code.blender.org/2015/10/debugging-python-code-with-pycharm/
https://b3d.interplanety.org/en/using-external-ide-pycharm-for-writing-blender-scripts/

40 Likes

Vim keys/modes would be cool.

4 Likes

Wow, on Github I found this CodeEditor add-on for Blender 2.72.

Why this hasn’t been included as an add-on in Blender many years ago is quite puzzling to me. This is an absolutely must have - it just needs to be updated to 2.80.

It includes minimap, tab indentation lines(!!!) and much more:
CodeEditor

Download:

9 Likes

I dont use the editor to code, more like a todo list, or to list frame numbers or things like that.

What bugs me is the behaviour of loosing focus when the mouse is not inside the editor, and instead of typing I trigger commands in some other editor.

I think the text editor should make an exception from this (otherwise excellent) behaviour.

2 Likes

Watch this one:
Text snippet tool to save your code in a library via text or python files.


https://www.youtube.com/watch?v=Rs4y7DeHkp8

Link for 2.79/2.80 Snippets Library

7 Likes

Back in 2008 there was a GSOC, which did work on the Text Editor, however it doesn’t look like the code was actually added to Blender. Does anyone know what happened? Could this still be useful?

https://developer.blender.org/rBSaa4e4da8c31a09c8afe0e60d26a1e68dd949e6b8

@riidom There is a new patch(suggestion) up, which deals with this problem:
https://developer.blender.org/D5047
Focus/no focus on the text editor:
image

@mkbreuer Excellent tip. I noticed in the video that his panel had a “Fix Whitespaces” button. Do you know what add-on has this much needed function?

@chalybeum Do you have a good link to somewhere describing what these vim keys/modes are, and which one you consider essential?

1 Like

Just search for Vim. It’s a really popular Texteditor under Linux.

1 Like

What would be nice is to be able to embed Vim as a text editor, some kind of live conntection. This has been done for things like Eclipse.

To fix whitespace, go to: header > format > convert whitespace

Here is an example how to extend the find panel:

bl_info = {
    "name": "Extended Find Panel",
    "description": "add a extended find & replace panel to the text editor sidebar",
    "author": "MKB",
    "version": (0, 0, 1),
    "blender": (2, 80, 0),
    "location": "Text editor > toolbar",
    "warning": "",
    "wiki_url": "",
    "category": "Text Editor" }


import bpy

# draw the panel
class EXTENDED_FIND_PT_ui_panel(bpy.types.Panel):
    """creates a panel the text editor sidebar"""
    bl_idname = 'EXTENDED_FIND_PT_ui_panel'
    bl_space_type = "TEXT_EDITOR"
    bl_region_type = "UI"
    bl_label = "Extended"
    bl_category = "T+"

    def draw(self, context):
        layout = self.layout
        
        st = context.space_data

        # find
        col = layout.column(align=True)
        row = col.row(align=True)
        row.prop(st, "find_text", text="")
        row.operator("text.find_set_selected", text="", icon='TEXT')
        col.operator("text.find")

        col.separator()

        # duplicate
        col = layout.column(align=True)
        row = col.row(align=True)

        row.operator("text.jump", text=" ", icon='FRAME_NEXT')
        row.operator("text.convert_whitespace", text=" ", icon='SHORTDISPLAY').type='SPACES'
        row.operator("text.uncomment", text=" ", icon='RESTRICT_VIEW_OFF')
        row.operator("text.comment", text="#", icon='RESTRICT_VIEW_ON')
        col.operator("text.duplicate_line", text="Duplicate")


        col.separator()

        # replace
        col = layout.column(align=True)
        row = col.row(align=True)
        row.prop(st, "replace_text", text="")
        row.operator("text.replace_set_selected", text="", icon='TEXT')
        col.operator("text.replace")

        # settings
        row = layout.row(align=True)
        row.prop(st, "use_match_case", text="Match")
        row.prop(st, "use_find_all", text="All")     

        row = layout.row(align=True)
        row.prop(st, "use_find_wrap", text="Wrap")

        row = layout.row(align=True)
        st = context.space_data
        row.prop(st, "show_margin", text="")
        row.prop(st, "margin_column", text="Margin")


        layout.separator()

        wm = context.window_manager 

        row = layout.column(align=True)
        row.operator("screen.userpref_show", text="UserPref", icon='PREFERENCES')
        row.operator("wm.save_userpref", text="SavePref", icon='FILE_TICK')    

        row.separator()

        #row.prop(context.scene, "debug_mode", text="Debug Mode", icon='SCRIPT')
        row.operator("wm.console_toggle", text="Open Console", icon='CONSOLE')             


        row = layout.row(align=True)
        row.operator("text.save", text="Save File", icon='FILE_TICK')
        row.operator("text.save_as", text="Save As", icon='FILE_TICK')
        row.operator("text.unlink", text="", icon='PANEL_CLOSE')


        layout.separator()



classes = (
EXTENDED_FIND_PT_ui_panel,
)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()
2 Likes

@kkar I noticed that the Text Editor UI wasn’t right aligned like the rest of 2.80, and I made a patch to fix this. @William and I continued to do UI changes in PMs, however it is not only the TE UI that has been somewhat neglected over the years(like the VSE), it is also the functionalities. Personally, I would say that it needs to be good enough to commit error free patches and add ons.

@mkbreuer One of the troubles committing code from the TE is that there is no way of detecting trailing whitespaces in order to clean them up. You can convert them, yes, but there is no function to make them visible or to ex. auto-remove trailing whitespaces(afaik). That was my reason for asking. If the codeeditor.py add-on could be updated to 2.80, maybe a function to draw (trailing?) whitespace a could be added?

The 2.80 TE UI patch: https://developer.blender.org/D5028
(The latest redesign is to move everything from the panel into the menu, except the Search and Replace)

1 Like

That’s the goal of NeoVim. To be easily integrated into other software. But I’m not able to say how feasible this really is.

The CodeEditor add-on I mentioned above contains imo some vital functions and should without question be added as an official Blender included add-on, however it was written for 2.73(and works flawless in that version of Blender) and needs to be updated to 2.80. I’ve updated a few obvious things without success. The original coder doesn’t reply on Github and hasn’t been active the last 5 years. The script is far too advanced for me, and I need some help from you guys to adopt and update it. Anyone got some time and skills to spare?

Script for print and error messages in the built-in python console:
Log.py: Route system output (stdout/stderr) of Blender to the app console (put in scripts/startup)

If you’re like me and use print to console a lot for debugging, and would prefer the print-outs to the built-in python console instead of the external system console, this, log.py script by tamask is godsend:
log

Download:

1 Like

#TextEditorReworked
Adding simple python operators to improve the long neglected Blender Text Editor:

  • Trim whitespaces.
  • Convert Case.
  • Split/Join lines.
  • Insert punctuation.


#b3d

1 Like

If you want to contribute to reworking the text editor through pyhon operators, you can find the files here: https://github.com/tin2tin/Text_Editor_Reworked
These are python files which could be included as built-in files in the official Blender. So in other words the feature set of the text editor can be improved with python alone.

Currently, I only added a few operators with my limited skills as a python coder. The new functions can be seen on the screenshot above.

  • Trim Whitespaces: Trailing & Leading
  • Split/Join
  • Convert Case to: CamelCase, snake_case, UPPERCASE, lowercase, Capitalize.
  • Insert Punctuations

A Blender Beta built with the files included, can be downloaded here(for a few days), or else read on Github how to add the files to your own Blender build: https://wetransfer.com/downloads/55d6acfc7a2494445d0fee8bf32eec6120190619104611/34d20b1c92f6568edfa605a57014ffe920190619104611/b8ae94

what I miss the most is being able to collapse functions / classes, this is a must if you work with big files.
But IMO text editor is great as it is, a quick way to test things. What would be best to me is being able to better work with ATOM or Sublime , maybe I should look more into VSCode.

3 Likes

I use the text editor for fast snippets and addon prototyping and thought the text formatting options could be better, so I’ve written a couple of convenience operators.

The most recent one is called Insert 2 and tries to emulate the behavior of modern IDEs in regard to how text is formatted. It’s a work in progress.

insert2

If you’d like to test it, you can get it on github. There’s still some behavior I need to improve to have it work consistently, though.

https://github.com/K-410/blender-scripts/blob/master/text_insert2.py

2 Likes

Wow, that looks really great. A bit like the punctuations operator on steroids!
I actually removed that function in this commit: https://developer.blender.org/D5097

Maybe you can take a look at that commit or at this github https://github.com/tin2tin/Text_Editor_Reworked , and turn your code into something nice and tight in a similar style ‘’, which can be submitted as a python operator which potentially can be included in Blender(the way this works, is to submit a patch, and let the devs decide what to include and what not.)

Will give it a test run, when I have a spare moment.

[EDIT: wow, you have made several BTE addons looking forward to test them out. What I was trying to write above is that if we can have python operator file loaded when Blender startsup, like most of the other editors, we can expand the functionality of the BTE with python. And what you’re doing are much needed functions imo, and they should absolutely be candidates for inclusion. But the first step is to have an python operator file accepted, hence my commit mentioned above. If you feel my commit can be improved, please do so. :slight_smile: ]

1 Like