Cursor Position
When you expand a snippet, the cursor is placed at the end of the snippet by default. However, you can change the cursor position to any place in the snippet.
It is useful when you want to start typing at a specific place in the snippet.
Setting Cursor Position
To set the cursor position, use the {@cursor@}
placeholder. You can add it
manually or by using the Set Cursor button. You can also use the CMD + P
shortcut.
Only one cursor placeholder is allowed in a snippet.
Under The Hood
Snippety doesn't have access to the content of text fields. In order to set the
cursor position, Snippety calculates the position based on the length of the
snippet and the position of the {@cursor@}
placeholder and simulates the left
arrow key presses to move the cursor to the desired position.
Some applications may not support this feature or may not be able to handle key presses that are simulated with high frequency. In such cases, the cursor may be displaced or the snippet may not work as expected.
Also, some applications may convert the input to a different format. For example, tab characters may be converted to spaces. This can affect the cursor position calculation and the snippet may not work as expected.
Long Templates
If you have a long template, it may take some time to move the cursor to the desired position. It is recommended to keep the cursor position close to the end of the snippet to avoid long delays.
Cursor Position & Simulated Keys
If you need to use the cursor placeholder together with simulated keys, the cursor placeholder is only allowed after the last simulated key.