Skip to content

IDE Scripts for Text Insertion

Working on the Xojo family of products, I spend a lot of time copying and pasting text into of the code editor and I really hate wasting time. One particularly challenging thing is bringing text into the code editor that contains quotes because they all need to be doubled up to work. For example for text that looks like this:


If you wanted to use that in a string, you need to double up each of those quotes to make them work:

dim sql as string = "CREATE TABLE ""PendingControllers"" (""id"" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ""name"" TEXT, ""ip"" TEXT)"

One line isn’t bad, but if you have a bunch to do, it can become quite tedious.

IDE Scripts to the rescue! With a simple script (less than 10 lines) you can have the IDE do this for you automatically.

  1. In the Xojo IDE, select File > IDE Scripts > New IDE Script
  2. In the script editor place the following code:
    // Get the text from the clipboard
    Dim c As String = Clipboard
    // Double up all of the quotes
    c = c.ReplaceAll("""","""""")
    // Insert the text into the code editor
    SelText = c
  3. Select File > Save As and save the script to the “Scripts” folder next to the IDE.

Now whenever you have quoted text to paste into the IDE, just select your script from the File > IDE Scripts menu instead!