Text Editor

Blender has a Text Editor among its editor types, accessible via the Editor type menu, or the shortcut Shift-F11.

Header

The newly opened Text editor is empty, with a very simple header. More options become available when a text file is created or opened.

../_images/editors_text-editor_header.png

Text header.

../_images/editors_text-editor_header-loaded.png

Text header with a text loaded.

Editor Type

The standard editor selection button.

Menus

Editor’s menus.

Resolve Conflict

Resolves modified file conflicts when an external text file is updated from another program.

  • Reload from Disk

    Opens the file from drive again, overriding any local changes.

    Make Text Internal

    Converts the external text data-block into an internal one.

    Ignore

    Hides the warning message until the external text file is modified externally again.

Text

A data-block menu to select a text or to create a new one. After that the header will change.

Run Script (play icon)

Executes the text as a Python script Alt-P. See Template Menu.

Show

Toggle display options.

Line Numbers, Word Wrap, Syntax Highlighting

Script Node Update (refresh icon)

When an OSL-file is opened, this updates the Shader Script node with new options and sockets from the script.

View Menu

Sidebar Ctrl-T

Show or hide the Sidebar.

Line Numbers

Displays the text file’s line numbers on the left of the Main View.

Word Wrap

Wraps words that are too long to fit into the horizontal space by pushing them to a new “pseudo line”.

Syntax Highlight

Colors special words, in the Main View, that are used in the Python programming language.

Highlight Line

Emphasizes the active line by altering the color of the background.


Zoom In/Out

Increase/decrease the font size of text in the main view.


Navigation

  • Top Ctrl-Home

    Moves the view and cursor to the start of the text file.

    Bottom Ctrl-End

    Moves the view and cursor to the end of the text file.

    Line Begin Home

    Moves the cursor to the start of the current line.

    Line End End

    Moves the cursor to the end of the current line.

    Previous Line Up

    Moves the cursor to the same position in the line above the current line.

    Next Line Down

    Moves the cursor to the same position in the line below the current line.

    Previous Word Ctrl-Left

    Moves the cursor to the beginning of the previous word. If the cursor is in the middle of a word, the cursor is moved to the beginning of the current word.

    Next Word Ctrl-Right

    Moves the cursor to the end of the next word. If the cursor is in the middle of a word, the cursor is moved to the end of the current word.

Text Menu

New Alt-N

Creates a new text Data Block.

Open Alt-O.

Loads an external text file that is selected via the File Browser.

Reload Alt-R

Reopens (reloads) the current buffer (all non-saved modifications are lost).

Edit Externally

Edit text file in external text editor. The external editor can be configured in the User Preferences.

Save Alt-S

Saves an already open file.

Save As Shift-Ctrl-Alt-S.

Saves text as a new text file, a File Browser is opened to select the directory to save the file along with giving the file a name and file extension.

Register

Run the text data-block as a Python script on loading the blend-file. Read more about the registration of Python modules in API documentation.

Live Edit

Run the Python script while editing

Run Script Alt-P

Executes the text as a Python script, see Running Scripts for more information.

Edit Menu

Undo/Redo

See Undo & Redo.

Cut Ctrl-X

Cuts out the marked text into the text clipboard.

Copy Ctrl-C

Copies the marked text into the text clipboard.

Paste Ctrl-V

Pastes the text from the clipboard at the cursor location in the Text editor.

Duplicate Line Ctrl-D

Duplicates the current line.

Move Line(s) Up Shift-Ctrl-Up

Swaps the current/selected line(s) with the above.

Move Line(s) Down Shift-Ctrl-Down

Swaps the current/selected line(s) with the below.

Find & Replace Ctrl-F

Shows the Find & Replace panel in the Sidebar.

Find & Set Selection Ctrl-G

Finds the next instance of the selected text.

Jump To Ctrl-J

Shows a pop-up, which lets you select a line number where to move the cursor to.

Text Auto Complete Tab

Shows a selectable list of words already used in the text.

Text to 3D Object

Converts the text file to a Text Object either as One Object or One Object Per Line.

Select Menu

All Ctrl-A

Selects the entire text file.

Line Shift-Ctrl-A

Selects the entire current line.

Word double-click LMB

Selects the entire current word.

Top Shift-Ctrl-Home

Selects everything above the cursor.

Bottom Shift-Ctrl-End

Selects everything below the cursor.

Line Begin Shift-Home

Selects everything between the beginning of the current line and the cursor.

Line End Shift-End

Selects everything between the cursor and the end of the current line.

Previous Line Shift-Up

Selects everything between the cursor and the position of the cursor one line above.

Next Line Shift-Down

Selects everything between the cursor and the position of the cursor one line below.

Previous Word Shift-Ctrl-Left

Selects everything between the cursor and the beginning of the previous word. If the cursor is in the middle of a word, select everything to the beginning of the current word.

Next Word Shift-Ctrl-Right

Selects everything between the cursor and the end of the next word. If the cursor is in the middle of a word, select everything to the end of the current word.

Format Menu

Indent Tab

Inserts a tab character at the cursor.

Unindent Shift-Tab.

Unindents the selection.

Toggle Comments Ctrl-Slash.

Toggles whether the selected line(s) are a Python comment. If no lines are selected the current line is toggled.

Convert Whitespace

Converts indentation characters To Spaces or To Tabs.

Template Menu

The Text Editor has some dedicated Python scripts, which are useful for writing tools, like a class/function/variable browser, completion…

Python, OpenShading Language

Main View

Typing on the keyboard produces text in the text buffer.

As usual, pressing, dragging and releasing LMB selects text. Pressing RMB opens the context menu.

Tip

Usages for the Text editor

The Text editor is handy also when you want to share your blend-files with others. The Text editor can be used to write in a README text explaining the contents of your blend-file. Be sure to keep it visible when saving!

Sidebar

Find & Replace

Find Text Ctrl-F

Searches for instances of a text that occur after the cursor. Using the eyedropper icon will search for the currently selected text and sets the selection to the match. Find Next searches for the next instance of the text.

Replace Text Ctrl-H

Searches for the text specified in Find Text and replaces it with the new text. Using the eyedropper icon will set the currently selected text as the replace text. Replace searches for the next match and replaces it. Replace All searches for the match and replaces all occurrences of the match with the new text.

Case

Search is sensitive to upper-case and lower-case letters.

Wrap

Search again from the start of the file when reaching the end.

All

Search in all text data-blocks instead of only the active one.

Properties

Margin

Shows a right margin to help keep line length at a reasonable length when scripting. The width of the margin is specified in Margin Column.

Font Size Ctrl-WheelUp

The size of the font used to display text.

Tab Width

The number of character spaces to display tab characters with.

Indentation

Use Tabs or Spaces for indentations.

The Text editor footer displays if the text is saved internal or external and if there are unsaved changes to an external file. For external files, this region also displays the file path to the text file.

Usage

Running Scripts

The most notable keystroke is Alt-P which makes the content of the buffer being parsed by the internal Python interpreter built into Blender. Before going on it is worth noticing that Blender comes with a fully functional Python interpreter built-in, and with a lots of Blender-specific modules, as described in the Scripting & Extending Blender section.