# Text commands

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

These are general String-related commands that are useful when used with the other IDE Scripting commands.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                           | Type                               | Read-Only | Shared |
|----------------------------------------------------------------|------------------------------------|-----------|--------|
| `Clipboard<ide_scripting_text_commands.clipboard>`             | `String</api/data_types/string>`   |           |        |
| `EndOfLine<ide_scripting_text_commands.endofline>`             | `String</api/data_types/string>`   | ✓         |        |
| `SelectionLength<ide_scripting_text_commands.selectionlength>` | `Integer</api/data_types/integer>` |           |        |
| `SelectionStart<ide_scripting_text_commands.selectionstart>`   | `Integer</api/data_types/integer>` |           |        |
| `SelectedText<ide_scripting_text_commands.selectedtext>`       | `String</api/data_types/string>`   |           |        |

## Property descriptions

<div id="ide_scripting_text_commands.clipboard">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**Clipboard** As `String</api/data_types/string>`

> Used to get or set the text contents of the OS clipboard.
>
> Create a new Note for the selected project item and pastes in the contents of the Clipboard into the Note:
>
> ``` xojo
> DoCommand("NewNote")
> Text = Clipboard
> ```

<div id="ide_scripting_text_commands.endofline">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**EndOfLine** As `String</api/data_types/string>`

> Returns the default line ending for the OS running the IDE. This is also the line separator used for code editor text that is returned by Text and SelectedText.
>
> This property is read-only.
>
> Add text to a new note:
>
> ``` xojo
> DoCommand("NewNote")
> Text = "Line1" + EndOfLine + "Line2"
> ```

<div id="ide_scripting_text_commands.selectionlength">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**SelectionLength** As `Integer</api/data_types/integer>`

> Gets or sets the length of characters in the current selection of the code editor.

<div id="ide_scripting_text_commands.selectionstart">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**SelectionStart** As `Integer</api/data_types/integer>`

> Gets or sets the offset of the selection (or insertion) point in the code editor.

<div id="ide_scripting_text_commands.selectedtext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

**SelectedText** As `String</api/data_types/string>`

> Gets or sets the selected text in the code editor. After assign a string to SelectedText, the selection will be empty and positioned immediately after the inserted text.
>
> Take the selected text and add an inline constant containing the text to the top of the method and replaces the selected text with the name of the constant:
>
> ``` xojo
> Var constantText As String
> constantText = SelectedText
>
> Var newConstant As String
> newConstant = "Const kValue = """ + constantText + """"
>
> SelectionStart = SelectionStart - 1
> SelectionLength = SelectionLength + 2
> SelectedText = "kValue"
>
> Text = newConstant + EndOfLine + EndOfLine + Text
> ```
