Text actions
Text actions are used to insert, replace, highlight, delete or unselect text in the editor.
Most of these actions make use of the path
property to specify the location of the file.
Positioning text/code
For the positioning of the text to insert, there are two options:
- Use the
position
property to specify the location where the action should be performed. With this property, you can specify the line number, character position, or a range of lines and characters. - Use the
startPlaceholder
andendPlaceholder
properties to specify the text to search for in the file to determine the location where the action should be performed.
Line position or range
For the position
property, you can use the following values:
number
: The line numbernumber:number
: The start and end line numbernumber,number
: The start line and characternumber,number:number,number
: The start line and character and the end line and character- The
start
andend
keywords can also be used instead of the line numbersstart
will be replaced by the first line numberend
will be replaced by the last line number
Examples:
"position": "10" // Line 10"position": "10:20" // Lines 10 to 20"position": "10,5" // Start line 10, character 5"position": "10,5:20,10" // Start line 10, character 5 to end line 20, character 10"position": "start" // First line"position": "end" // Last line
position: "10" # Line 10position: "10:20" # Lines 10 to 20position: "10,5" # Start line 10, character 5position: "10,5:20,10" # Start line 10, character 5position: start # First lineposition: end # Last line
Placeholder position
For the startPlaceholder
and endPlaceholder
properties, you specify the text to search for in the file.
Examples:
"startPlaceholder": "// Start of demo1""endPlaceholder": "// End of demo1"
startPlaceholder: // Start of demo1endPlaceholder: // End of demo1
In the file, the placeholders should be defined like this:
// Start of demo1const ext = 'Demo Time';// End of demo1
Highlight text
Highlight text in the editor at a specific location.
// Via position{ "action": "highlight", "path": "<relative path to the file>", "position": "<position>", "zoom": "<zoom level> (optional)"}
// Via placeholders{ "action": "highlight", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "highlightWholeLine": "<highlight whole line (optional, default is true)>", "zoom": "<zoom level> (optional)"}
# Via positionaction: highlightpath: <relative path to the file>position: <position>zoom: <zoom level> # Optional
# Via placeholdersaction: highlightpath: <relative path to the file>startPlaceholder: <start placeholder>endPlaceholder: <end placeholder>highlightWholeLine: <highlight whole line (optional, default is true)>zoom: <zoom level> # Optional
Position cursor
Position your cursor in the editor at a specific location.
// Via position{ "action": "positionCursor", "path": "<relative path to the file>", "position": "<position>"}
// Via start placeholder{ "action": "positionCursor", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>",}
# Via positionaction: positionCursorpath: <relative path to the file>position: <position>
# Via start placeholderaction: positionCursorpath: <relative path to the file>startPlaceholder: <start placeholder>
Insert text
Insert text in the editor at a specific location.
// Via position{ "action": "insert", "path": "<relative path to the file>", "position": "<position>", "content": "<content of the file> (optional)", "contentPath": "<relative path to the file (optional)>", "insertTypingMode": "<typing mode: 'instant', 'line-by-line' or 'character-by-character'> (optional, default is 'instant')", "insertTypingSpeed": "<delay in milliseconds to insert (optional)>"}
// Via placeholders{ "action": "insert", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "content": "<content of the file> (optional)", "contentPath": "<relative path to the file (optional)>", "insertTypingMode": "<typing mode: 'instant', 'line-by-line' or 'character-by-character'> (optional, default is 'instant')", "insertTypingSpeed": "<delay in milliseconds to insert (optional)>"}
# Via positionaction: insertpath: <relative path to the file>position: <position>content: <content of the file> # optionalcontentPath: <relative path to the file> # optionalinsertTypingMode: <typing mode: 'instant', 'line-by-line' or 'character-by-character'> # optional, default is 'instant'insertTypingSpeed: <delay in milliseconds to insert> # Optional
# Via placeholdersaction: insertpath: <relative path to the file>startPlaceholder: <start placeholder>endPlaceholder: <end placeholder>content: <content of the file> # optionalcontentPath: <relative path to the file> # optionalinsertTypingMode: <typing mode: 'instant', 'line-by-line' or 'character-by-character'> # optional, default is 'instant'insertTypingSpeed: <delay in milliseconds to insert> # Optional
Replace text
Replace text in the editor at a specific location.
// Via position{ "action": "replace", "path": "<relative path to the file>", "position": "<position>", "content": "<content of the file> (optional)", "contentPath": "<relative path to the file (optional)>", "insertTypingMode": "<typing mode: 'instant', 'line-by-line' or 'character-by-character'> (optional, default is 'instant')", "insertTypingSpeed": "<delay in milliseconds to insert (optional)>"}
// Via placeholders{ "action": "replace", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "content": "<content of the file> (optional)", "contentPath": "<relative path to the file (optional)>", "insertTypingMode": "<typing mode: 'instant', 'line-by-line' or 'character-by-character'> (optional, default is 'instant')", "insertTypingSpeed": "<delay in milliseconds to insert (optional)>"}
# Via positionaction: replacepath: <relative path to the file>position: <position>content: <content of the file> # optionalcontentPath: <relative path to the file> # optionalinsertTypingMode: <typing mode: 'instant', 'line-by-line' or 'character-by-character'> # optional, default is 'instant'insertTypingSpeed: <delay in milliseconds to insert> # Optional
# Via placeholdersaction: replacepath: <relative path to the file>startPlaceholder: <start placeholder>endPlaceholder: <end placeholder>content: <content of the file> # optionalcontentPath: <relative path to the file> # optionalinsertTypingMode: <typing mode: 'instant', 'line-by-line' or 'character-by-character'> # optional, default is 'instant'insertTypingSpeed: <delay in milliseconds to insert> # Optional
Write single line
Write a single line of text in the editor at the current location or specific location.
// Write to current active position{ "action": "write", "content": "Hello World"}
// Write to a specific position in a file// Via position{ "action": "write", "content": "Hello World", "path": "<relative path to the file>", "position": "<position>"}
// Via start placeholder{ "action": "write", "content": "Hello World", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>",}
# Write to current active positionaction: writecontent: "Hello World"
# Write to a specific position in a file# Via positionaction: writecontent: "Hello World"path: <relative path to the file>position: <position>
# Via start placeholderaction: writecontent: "Hello World"path: <relative path to the file>startPlaceholder: <start placeholder>
Format text
Format the content of the active file.
{ "action": "format"}
action: format
Unselect text
Unselect or undo text highlighting in a specific file.
{ "action": "unselect", "path": "<relative path to the file>"}
action: unselectpath: <relative path to the file>
Delete text
Delete text in the editor at a specific location.
// Via position{ "action": "delete", "path": "<relative path to the file>", "position": "<position>"}
// Via placeholders{ "action": "delete", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>"}
# Via positionaction: deletepath: <relative path to the file>position: <position>
# Via placeholdersaction: deletepath: <relative path to the file>startPlaceholder: <start placeholder>endPlaceholder: <end placeholder>