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.
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', 'character-by-character', 'hacker-typer'> (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', 'character-by-character', 'hacker-typer'> (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', 'character-by-character' or 'hacker-typer'> # 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', 'character-by-character' or 'hacker-typer'> # 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', 'character-by-character' or 'hacker-typer'> (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', 'character-by-character' or 'hacker-typer'> (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', 'character-by-character' or 'hacker-typer'> # 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', 'character-by-character' or 'hacker-typer'> # 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"}
action: unselect
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>
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
Typing modes
When inserting or replacing text, you can specify the typing mode with the insertTypingMode
property or on global level with the demoTime.insertTypingMode
setting.
The available options are:
instant
: The text is inserted instantly.line-by-line
: The text is inserted line by line, with a delay between each line.character-by-character
: The text is inserted character by character, with a delay between each character.hacker-typer
: The text is inserted in a hacker-typer style, where you are in control over the character instertion by pressing thedown
key (default key binding which can be changed in the keybindings settings).
Hacker-typer mode
When you use the hacker-typer
mode, you can trigger the text insertion by pressing the down
key on your keyboard. The text will be inserted in a hacker-typer style, where you are in control over the character insertion.
The demoTime.hackerTyperChunkSize
setting allows you to define how many characters are inserted per ‘keystroke’. The default value is 3
, which means that three characters are inserted each time you press the down
key.
The down
key is linked as a keybinding to the Demo Time: Hacker Typer next chunk
(demo-time.hackerTyperNextChunk
) command. You can change this keybinding in the keybindings settings.
When you enter the hacker-typer
mode, you will see a keyboard icon in the status bar indicating that you are in hacker-typer mode and it will be removed when you have entered all the text.
