The code editor
A double click on a script (or any .cs, .txt, .json, .md, .shader file), a click on a script error in the Console, or Assets > Create > Script Templates opens the file in the editor's own code editor. It edits the file on disk: Ctrl+S saves, closing the window saves what was changed, and a file changed by another program is read again while it has no changes of its own.
Keys
| Ctrl+S | save |
| Ctrl+Z, Ctrl+Y / Ctrl+Shift+Z | undo, redo (typing is grouped) |
| Ctrl+C, Ctrl+X, Ctrl+V | copy, cut, paste (with nothing selected: the whole line) |
| Ctrl+A | select all |
| Ctrl+F, Ctrl+H | find, find and replace (Aa: match case; Enter: next) |
| Ctrl+G | go to line |
| Ctrl+P | switch to any text file of the project by typing part of its name |
| Ctrl+B, Ctrl+click | go to where a name is declared (this file, then the project's other scripts) |
| Ctrl+Space | suggestions with nothing typed |
| Ctrl+/ | comment or uncomment the lines |
| Ctrl+D, Ctrl+Shift+K | duplicate the line, delete the line |
| Alt+Up, Alt+Down | move the lines |
| Tab, Shift+Tab | indent, take indent off (Tab also takes the next stop of a snippet) |
| Alt+Shift+F | Format Document: indent by braces (one undo step) |
| Ctrl+W | close the tab |
| Ctrl+Tab, Ctrl+Shift+Tab | the next tab, the one before |
| Ctrl+Shift+T | opens the tab closed last again |
| Ctrl+Shift+S | saves every tab with changes |
| Ctrl+Shift+M | the minimap on or off |
| a middle click on a tab | closes it |
| Ctrl + / Ctrl - / Ctrl 0, Ctrl and the wheel | the code's text size bigger, smaller, as it was (50% to 300%) |
| Alt+Z | word wrap on or off: long lines continue on the next row |
| F2 | rename the name under the caret in every script of the project (whole words in code; strings and comments are left) |
| Ctrl+Shift+O | go to a name this file declares (types and their members) |
| Ctrl+Shift+F | find text in every text file of the project; Enter or a click opens the match |
| the arrow in the gutter | folds a block away ({ ...}), and opens it again |
| Esc | close the suggestions, the find bar, a selection |
Typing closes (), [], {}, "" and '', types over a closing one that is already there, and indents after a brace (Enter between { and } opens a body). A selection typed over with an opener is wrapped.
Tabs, the minimap and a window of its own
The tabs scroll when there are more than fit (the wheel over them, or the arrows at their ends); the file in use is underlined, a dot marks a file with changes, and the full path shows when the pointer rests on a tab. The file's path is written above it, and a minimap beside the scroll bar shows the whole file small (a click or a drag on it goes there).
The button beside the close button (and Window > Code Editor Window) opens the code editor in a program window of its own, neux code --project DIR FILE...: you switch between it and the editor like two programs. It edits the same files on disk; the editor reads what it saves. Closing it saves what was typed.
IntelliSense
- Members after a dot:
transform.lists what a Transform has; chains (transform.position.),GetComponent<Rigidbody>()., locals (Rigidbody rb;,var v = new Vector3(...)),this.and static types (Mathf.,Mode.) are followed. - Names: keywords, the engine's types, this class and the bases it inherits (
gameObject,transform), names declared in the file, boilerplates. Typing narrows by prefix, by capitals (gcfindsGetComponent) or by letters in order. - **
override** lists the hooks of the base class (Update, OnTriggerEnter...) and writes the whole method out. - **
[** at the start of a line lists attributes (SerializeField,Header,Range...). - Parameter hints over a call: the overloads, and the parameter being typed marked.
- Documentation: the
///comments of the engine's API and of the project's scripts show beside the list and when the pointer rests on a name. - Problems: what the last check found, for all the scripts, is listed in a strip above the status bar (a click goes to the line; "hide" puts it away until the next check).
- Compiler errors: saving a script builds the project's scripts on a thread of its own; what the compiler finds goes to the Console and marks its line in the file (red mark and line, hover for the message), and goes when the script is fixed and saved. The status bar says "Checking the scripts...", then "The scripts compile" or how many errors.
What IntelliSense knows is read from the engine's own C# API source and from every script of the project, so a new public method completes as soon as its file is saved.
Boilerplates
Snippets (type the trigger, then Tab or Enter): behaviour, start, update, fixedupdate, lateupdate, awake, oncollision, ontrigger, coroutine, field, serialized, header, range, getcomponent, find, spawn, log, input, key, move, timer, menuitem, contextmenu, customeditor, gizmos, if, ifelse, for, foreach, while, switch, try, prop, enum, class, struct, region. Tab goes through the stops; a stop used several times (i in a for) is typed once.
Assets > Create > Script Templates makes a whole file: Player Controller, Health, Pickup, Game Manager, Spawner, Follow Target, State Machine, Coroutine Sequence, Static Utility, Custom Inspector, Editor Window. Every template compiles as it is (a test builds each with the script host).
Not there yet
Multiple cursors, errors while typing (they come on save), rename that understands types (it renames by name, in code), find and replace across files, semantic colours for user types, format-on-save, themes.