Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


The TouchDevelop editor provides a number of tools which are designed to make coding more efficient. In this guide we'll cover copying and pasting, then move on to the powerful refactoring features.

copy and paste

You surely know about copy and paste! In TouchDevelop you can copy a sequence of tokens, a bunch of lines of code, or an entire declaration (like an action or global definition).
To copy or cut tokens (the "words" which describe the code) double tap on the token where you want to begin your selection, and then drag the markers. You can also use the extend selection key that displays after a selection is begun. If you have a keyboard you can use Shift-Left or Shift-Right. Once you're happy with the selection, just tap the round copy or cut button (they are now green to indicate that tokens, not lines of code, will be affected).
To copy or cut a single line of code just select it and tap the round copy or cut button. To paste it, start a new line of code where you want to paste, and use the round paste button.
To copy or cut multiple lines of code select the first line (or last), and tap the round select button. Then drag the markers up and down. You can also use Shift-Up or Shift-Down. You will see rectangular cut and copy buttons on the side of screen.
To copy or cut an action select the action header (eg., action main()) and tap the copy or cut button. To paste an action tap on any line of code and then tap the round paste. A copy of the action will be inserted into your script project.

extract to local and simplify

To extract tokens to a new local variable select one or more tokens, then click the extract to local button. This will create a new local variable initialized with the selected tokens, and then insert a reference to this variable (in place of the tokens).
The simplify button will try to automatically extract some locals to make the expression simpler. If it doesn't do what you want use the undo button.

extract to parameter

To extract a token to a parameter of the current action, select a token (it should be a literal like "string", 42, or true), then click the extract to parameter button. All current callers will be updated to pass this parameter.

promote to global and demote to local

To turn a local variable into a global variable, select the variable and click the promote to global button.
A demote to local button is also provided. It may not work as expected if the global is used in more than one action.

promote to field

Globals and locals can be promoted to fields of objects, provided there is a local or global of object type in the current scope.


To replace a token or sequence of tokens, first copy the token that will be the replacement, then select the token(s) to replace and click either replace all in script or replace all in action. You will be presented with a number of choices in addition to the current contents of the clipboard.

extract action

To extract one or more lines of code into a new action, select the code (with the round select button), then tap extract action. This will create a new action, insert the code you copied, and insert a call to the newly created action in the previous location.

surround with control flow or comment

To surround one or more lines of code with a control flow block select the lines using the select tool, then choose an option under surround with:
  • if
  • for
  • for each
  • while
  • boxed
  • comment out

move to library

If your script is getting too large, think about using the move to library refactoring feature to split your script into smaller and more manageable components.