Editor Workspace
The Editor Workspace is the left panel of the Pine Script AI Editor. It provides a professional code editing environment with multi-tab support, syntax highlighting, and automatic saving.
Layout Overview
Section titled βLayout Overviewβββββββββββββββββββββββββββββββββββββββββββββββββ [Tab 1] [Tab 2] [Tab 3] [+] β β Tab Barβββββββββββββββββββββββββββββββββββββββββββββββ€β ββ //@version=6 ββ strategy("My Strategy", overlay=true) β β Code Editorβ ... ββ ββββββββββββββββββββββββββββββββββββββββββββββββ€β Errors (0) Warnings (0) β Valid β β Validation StatusβββββββββββββββββββββββββββββββββββββββββββββββTab Management
Section titled βTab ManagementβCreating Tabs
Section titled βCreating TabsβClick the + button in the tab bar to create a new script tab.
Tab types:
- Strategy β For full trading strategies with entries/exits
- Library β For reusable Pine Script libraries
Switching Tabs
Section titled βSwitching TabsβClick any tab to switch to it. Your code and cursor position are preserved.
Renaming Tabs
Section titled βRenaming TabsβDouble-click a tab name to rename it. Press Enter to confirm or Escape to cancel.
Closing Tabs
Section titled βClosing TabsβHover over a tab and click the Γ button to close it.
Warning: If you have unsaved changes, youβll be prompted to save first.
Tab Indicators
Section titled βTab Indicatorsβ| Indicator | Meaning |
|---|---|
| β (dot) | Unsaved changes |
| β (check) | All changes saved |
Code Editor Features
Section titled βCode Editor FeaturesβSyntax Highlighting
Section titled βSyntax HighlightingβThe editor provides Pine Script-specific syntax highlighting:
- Keywords β
strategy,indicator,if,for, etc. - Built-in Functions β
ta.rsi(),ta.ema(),strategy.entry(), etc. - Numbers β Literal values and constants
- Strings β Text in quotes
- Comments β Lines starting with
//
Auto-Indentation
Section titled βAuto-IndentationβThe editor automatically indents your code as you type:
- After
if,for,whilestatements - Inside function definitions
- Following line continuations
Autocomplete
Section titled βAutocompleteβWhen enabled, the editor suggests:
- Pine Script built-in functions
- Variable names from your code
- Common parameter names
Toggle autocomplete in the toolbar settings menu.
Line Numbers
Section titled βLine NumbersβLine numbers appear on the left side of the editor. These are essential for:
- Debugging error messages
- Referencing specific code sections
- Communicating with the AI about line-specific issues
Toolbar Actions
Section titled βToolbar ActionsβThe toolbar above the editor provides quick access to common actions:
| Icon | Action | Shortcut |
|---|---|---|
| πΎ | Save | Ctrl/Cmd + S |
| π | Copy Code | Ctrl/Cmd + C (all) |
| π₯ | Download as .pine | β |
| β | Validate | Ctrl/Cmd + Shift + V |
| βοΈ | Settings | β |
Settings Menu
Section titled βSettings MenuβAccess the settings gear icon to toggle:
- Autocomplete β Enable/disable code suggestions
- Auto-Validation β Automatically validate after changes
- Auto-Save β Save changes after 2 seconds of inactivity
Keyboard Shortcuts
Section titled βKeyboard ShortcutsβEditing
Section titled βEditingβ| Shortcut | Action |
|---|---|
Ctrl/Cmd + Z | Undo |
Ctrl/Cmd + Shift + Z | Redo |
Ctrl/Cmd + C | Copy selection |
Ctrl/Cmd + X | Cut selection |
Ctrl/Cmd + V | Paste |
Ctrl/Cmd + A | Select all |
Ctrl/Cmd + D | Duplicate line |
Navigation
Section titled βNavigationβ| Shortcut | Action |
|---|---|
Ctrl/Cmd + G | Go to line |
Ctrl/Cmd + F | Find |
Ctrl/Cmd + H | Find and replace |
Ctrl/Cmd + Home | Go to start |
Ctrl/Cmd + End | Go to end |
Multi-Cursor
Section titled βMulti-Cursorβ| Shortcut | Action |
|---|---|
Alt + Click | Add cursor |
Ctrl/Cmd + Alt + Up/Down | Add cursor above/below |
Ctrl/Cmd + Shift + L | Select all occurrences |
Auto-Save
Section titled βAuto-SaveβWhen enabled, auto-save works as follows:
- You make a change to your code
- After 2 seconds of no typing, the change is saved
- The tab indicator updates from β to β
Benefits:
- Never lose work due to browser crashes
- Changes persist across sessions
- No manual save required
When to disable:
- Working on experimental changes you might want to discard
- Making rapid iterations you donβt want saved individually
Undo/Redo History
Section titled βUndo/Redo HistoryβThe editor maintains a full history of your changes:
- Undo β Reverts the last change (
Ctrl/Cmd + Z) - Redo β Re-applies an undone change (
Ctrl/Cmd + Shift + Z)
History is preserved:
- Within a session (until you close the browser)
- Across tab switches
- After applying AI suggestions
Working with Selections
Section titled βWorking with SelectionsβShare Selection with AI
Section titled βShare Selection with AIβ- Select code in the editor
- Click Share Selection in the chat panel
- The selected code is attached to your next message
Use cases:
- βWhat does this function do?β (with function selected)
- βRefactor this sectionβ (with code block selected)
- βIs there a bug here?β (with suspicious code selected)
Selection Indicators
Section titled βSelection IndicatorsβWhen you have code selected:
- The status bar shows the selection line range
- The βShare Selectionβ button becomes active
- Selected code is highlighted in the editor
Validation Panel
Section titled βValidation PanelβBelow the editor, the validation panel shows:
No Issues
Section titled βNo Issuesββ Script is valid | No errors or warnings detectedWith Issues
Section titled βWith Issuesββ 2 Errors | β οΈ 1 Warning
Line 15: Undeclared identifier 'rsi_value' [Fix with AI]Line 23: Using deprecated function 'security' [Fix with AI]Click Fix with AI to automatically send the error to the AI for resolution.
Best Practices
Section titled βBest PracticesβOrganize Your Tabs
Section titled βOrganize Your Tabsβ- Keep one βmainβ version and create copies for experiments
- Name versions clearly (v1, v2, βwith stopsβ, etc.)
- Delete unused tabs to reduce clutter
Use Comments
Section titled βUse Commentsβ// === ENTRY CONDITIONS ===longCondition = ta.crossover(rsi, 30)
// === EXIT CONDITIONS ===exitCondition = ta.crossover(rsi, 70)Comments help you and the AI understand your code structure.
Save Before Major Changes
Section titled βSave Before Major ChangesβEven with auto-save, manually save before:
- Applying large AI suggestions
- Making significant refactors
- Testing experimental changes
Related Sections
Section titled βRelated Sectionsβ- AI Chat Panel β Using the AI assistant
- Diff Viewer β Reviewing AI suggestions
- Code Validation β TradingView compiler integration