This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Visual Studio Transpose Commands

Visual Studio's code editing tools include a large number of shortcut keystrokes that perform simple functions. This short article describes the transpose commands, which allow pairs of characters, words and lines of code to be switched.


Visual Studio's transpose commands allow you to swap the positions of two adjacent characters, words or lines in the code editor. To use one of the commands, position the text cursor, or caret, according to the item that you wish to move. For words and lines of code, place the caret anywhere within the text. To transpose characters, place the cursor between the two characters.

With the caret in the correct position, you can press the appropriate shortcut key combination. To transpose characters, press Ctrl-T, for words use Ctrl-Shift-T and for entire lines press Shift-Alt-T. After the item positions are swapped, the cursor moves so the subsequent use of the same command does not reverse the process, instead continuing to move the first item forward through the text.

The following image shows some sample text before transposing lines. Note that the caret is positioned at the end of the first line.

Visual Studio Transpose (Before)

On pressing Shift-Alt-T, the first line is moved beneath the second. The caret is now at the end of the second line:

Visual Studio Transpose (Before)

12 February 2011