Productivity features to write Clarion code faster.
The Clarion Extension provides powerful code editing tools:
- 50+ code snippets - Quick insertion of common structures
- Paste as Clarion String - Convert text to Clarion string format
- Add Method Implementation - Generate method stubs automatically
- Create New Class - Interactive class creation wizard
- Code folding - Collapse/expand code blocks
Shortcuts that expand into full code structures:
- Type the trigger word (e.g.,
IF) - Press Tab
- Full structure inserted with placeholders
- Tab again to jump to next placeholder
Trigger: IF
IF THEN
ENDTrigger: IFE (IF with ELSE)
IF THEN
ELSE
ENDTrigger: LOOP
LOOP
ENDTrigger: LOOPFT (LOOP with FROM/TO)
LOOP var = from TO to
ENDTrigger: LOOPFILE (File LOOP)
LOOP UNTIL ACCESS:FileName.Next()
ENDTrigger: CASE
CASE variable
OF value
ENDMAP→ MAP/ENDMODULE→ MODULE/ENDCLASS→ CLASS/ENDGROUP→ GROUP/ENDQUEUE→ QUEUE/ENDFILE→ FILE/END
Pattern: V{type} (V = Variable)
VS→Bar STRING(10)VL→Bar LONGVR→Bar REALVD→Bar DECIMAL(10,2)VDT→Bar DATEVTI→Bar TIME
Pattern: RV{type} (RV = Reference Variable)
RVS→Bar &STRINGRVL→Bar &LONGRVR→Bar &REAL
Pattern: PV{type} (PV = Procedure Variable)
PVS→(STRING Foo)PVL→(LONG Foo)
Pattern: PVR{type} (PVR = Procedure Reference)
PVRS→(*STRING Foo)PVRL→(*LONG Foo)
| Shortcut | Type |
|---|---|
s |
STRING |
l |
LONG |
r |
REAL |
d |
DECIMAL |
dt |
DATE |
ti |
TIME |
b |
BYTE |
sh |
SHORT |
ul |
ULONG |
us |
USHORT |
cs |
CSTRING |
ps |
PSTRING |
Converts clipboard text to Clarion string format:
- Automatically escapes quotes
- Converts unicode quotes to ASCII (for Clarion compatibility)
- Adds line continuation (
& |) - Handles multi-line text
- Perfect for SQL, error messages, multi-line strings
Note: Unicode "smart quotes" (', ', ", ") from Word, web browsers, etc. are automatically converted to ASCII quotes (' and ") to ensure Clarion compiler compatibility.
- Copy text to clipboard (any source)
- In VS Code, position cursor where you want string
- Press
Ctrl+Shift+Alt+V - Text pasted as Clarion string
Or:
Ctrl+Shift+P→ "Clarion: Paste as Clarion String"
Clipboard:
Hello World
Pasted:
'Hello World'Clipboard:
This is line 1
This is line 2
This is line 3
Pasted (default):
'This is line 1' & |
'This is line 2' & |
'This is line 3'Clipboard:
He said "Hello"
Pasted:
'He said "Hello"'Clipboard (with "smart quotes"):
SELECT * FROM Customers WHERE Name = 'John's Store'
Pasted (automatically converted to ASCII):
'SELECT * FROM Customers WHERE Name = ''John''s Store'''Note: Unicode quotes (', ', ", ") are converted to ASCII (' and ") before escaping. This ensures Clarion compiler compatibility.
Clipboard:
SELECT *
FROM Customers
WHERE Country = 'USA'
ORDER BY CustomerNamePasted:
'SELECT *' & |
'FROM Customers' & |
'WHERE Country = ''USA''' & |
'ORDER BY CustomerName'Note: Single quotes automatically doubled for SQL escaping!
Choose how lines are joined:
{
"clarion.pasteAsClarionString.lineTerminator": "space" // Default
}Options:
"space" - Join with space (default)
'Line 1' & |
'Line 2'"crlf" - Include CRLF characters
'Line 1' & |
'<13,10>' & |
'Line 2'"none" - No line breaks
'Line 1Line 2'Remove indentation from pasted text:
{
"clarion.pasteAsClarionString.trimLeading": true // Default
}Example with trim enabled:
Clipboard:
Indented line 1
Indented line 2
Pasted:
'Indented line 1' & |
'Indented line 2'Automatically generates method implementations from CLASS declarations:
- Finds the method declaration in CLASS
- Locates the MODULE file
- Checks for existing implementation
- Generates new implementation or jumps to existing
- Place cursor on method name in CLASS declaration
- Press
Ctrl+Shift+I - Implementation generated in MODULE file
- Cursor moves to new implementation
Or:
Ctrl+Shift+P→ "Clarion: Add Method Implementation"
In MyClass.inc:
MyClass CLASS,MODULE('MyClass.clw')
Init PROCEDURE() ← Cursor here, press Ctrl+Shift+I
ENDGenerates in MyClass.clw:
MyClass.Init PROCEDURE
CODE
! Your code hereHandles overloaded methods:
MyClass CLASS,MODULE('MyClass.clw')
Process PROCEDURE(STRING value)
Process PROCEDURE(*STRING reference) ← Generates correct signature
ENDGenerates:
MyClass.Process PROCEDURE(*STRING reference)
CODE
Uses parameter types to match correct overload!
If implementation already exists:
- Jumps to existing implementation
- Does NOT create duplicate
- Cursor positioned at implementation
Interactive wizard creates both .inc and .clw files:
- Prompts for class name
- Asks for folder location
- Creates
.incfile with CLASS declaration - Creates
.clwfile with MODULE stub - Opens both files
- Press
Ctrl+Shift+P - Type "Clarion: Create New Class"
- Enter class name (e.g.,
MyClass) - Select destination folder
- Files created and opened
MyClass.inc:
MyClass CLASS,MODULE('MyClass.clw'),TYPE,THREAD
Init PROCEDURE()
Kill PROCEDURE()
ENDMyClass.clw:
MEMBER('MyClass')
MAP
END
INCLUDE('MyClass.inc'),ONCE
MyClass.Init PROCEDURE
CODE
MyClass.Kill PROCEDURE
CODE
A batch of CodeRush-inspired refactors, available on Ctrl+. (or the Refactor… context menu) and as palette commands. None of them bind new keyboard shortcuts.
Select one or more statement lines, then Ctrl+. → Surround With… (or Clarion: Surround With… from the palette). Wraps the selection in:
IF … ENDLOOP … END,LOOP WHILE … END,LOOP UNTIL … ENDCASE … OF … END
The content is indented one level (relative indentation preserved, OF aligned with CASE), and the condition placeholder is selected so you can type straight over it.
With the cursor on an IF / ELSIF / LOOP WHILE / LOOP UNTIL line, flips the condition's logical sense: comparison operators invert (= ↔ <>, < ↔ >=, …), a bare expression gains/loses ~, and a compound boolean is wrapped in ~(…). Only the condition span is rewritten — trailing THEN, comments, and string contents are untouched.
On a block-form IF … ELSE … END, negates the condition and swaps the branches — handy when the ELSE holds the common/early path. Not offered when the shape isn't a clean two-branch flip (no ELSE, an ELSIF chain, or single-line IF … THEN), where Negate Condition still covers the IF line.
With the cursor on (or a selection of) a numeric or string literal, extracts the magic literal to a named EQUATE. A quick pick asks which data section it should live in — the routine's DATA, the procedure's local data, module data (in a MEMBER), global data (in a PROGRAM), or even cross-file into the resolved PROGRAM file's global section — then prompts for the name. The literal is replaced with the new name.
With the cursor on a DO SomeRoutine whose target doesn't exist, a quick fix scaffolds the SomeRoutine ROUTINE skeleton at the end of the enclosing procedure and drops the cursor into the body. Resolution is procedure-scoped (routine labels legally repeat across procedures), and from inside a local derived method (ABC's ThisWindow shape) it offers both placements — local to the method, or procedure-level shared by all methods.
Collapse/expand code blocks:
- Hides implementation details
- Focus on structure
- Navigate large files easier
All major Clarion structures:
- PROCEDURE/END
- CLASS/END
- IF/END
- LOOP/END
- CASE/END
- MAP/END
- GROUP/END
- ROUTINE/END
Fold/unfold block:
- Click ▼ icon in left gutter
- Or press
Ctrl+Shift+[(fold) - Or press
Ctrl+Shift+](unfold)
Fold all:
Ctrl+K Ctrl+0- Fold allCtrl+K Ctrl+J- Unfold all
Fold level:
Ctrl+K Ctrl+1- Fold level 1Ctrl+K Ctrl+2- Fold level 2- etc.
Keyboard shortcut: Shift+Alt+→ to expand, Shift+Alt+← to shrink
Progressively widens the text selection through Clarion's scope hierarchy:
- Current token
- Current line
- Innermost structure (
IF,LOOP,CLASS, etc.) - Parent structure
- Whole document
Shrink walks back through the same chain.
Example:
IF x > 0 THEN
DoSomething() ! ← Cursor here
DoOther()
END- First
Shift+Alt+→: selectsDoSomething() - Second: selects the line
- Third: selects the entire IF block
Keyboard shortcut: Ctrl+. on a continuation block
Command: "Clarion: Flatten Continuation Lines"
Joins |-continued lines into a single line:
- Trims whitespace from continuation segments
- Collapses adjacent string literals:
'abc' & 'def'→'abcdef' - Pipe characters inside string literals are never misread as continuation markers
Example:
Before:
MyString = 'Hello ' & |
'World' & |
' today'After:
MyString = 'Hello World today'Automatically closes:
(→()[→[]'→''"→""
Cursor positioned inside:
MyProc(|) ← Cursor here after typing (Matching brackets highlighted:
- Place cursor next to bracket
- Matching bracket highlighted
- Makes nested structures easier to read
- Type trigger
- Tab to expand
- Type placeholder value
- Tab to next placeholder
- Repeat until done
- Keep Paste as String shortcut handy
- Use for any multi-line text
- SQL queries, error messages, help text
- Use wizard for consistent structure
- Generates Init/Kill methods automatically
- Proper MODULE reference
- Fold completed procedures
- Focus on current work
- Unfold when needed
- Signature Help - Parameter hints for functions
- Snippets Reference - All available snippets
- Common Tasks - Usage examples