Visual Studio Tricks


Visual Studio (2005,2008,2010) Tips and Tricks.


#21 Transpose Characters, words, and lines in the editor

Moving text around is something we all need to do frequently. This trick shows you how to transpose characters (which is great for fixing typos), words, and lines with their neighbors. Characters flip with their neighbor to fix a type or spelling error. Words switch left and right to quickly move a word down the line (by repeating the process) and moving the line is a great way to move a line up or down without using cut/paste.

Click Screenshot To Play Video

#21 Transpose Characters, words, and lines in the editor

Runtime: 2Min - Resolution: 900 by 580 - File Size: 1.7Meg

Direct Download: If the video does not work for you,
Click Here to download it.

Snippets / Notes:

[CTRL]+T = Transpose a character

[CTRL]+[SHIFT]+T = Transpose a word

[ALT]+[SHIFT]+T = Transpose a line

Visual Studio Tip / Trick #021 English Transcription:

Today’s visual studio trick of the day, trick number 21 was originally published my Sara Ford in August of 2007. Today’s trick is transposing characters from the keyboard. You will notice my character.... My cursor is between L and A so if I press [CTRL]+[T] so you will see that those two characters are transposed. I go back I can transpose them again. What’s interesting about this is that this not only transpose the letters but it also then moves your cursor one to the right. So if you are to do some thing like [CTRL]+[T] multiple times you'll probably get strange set of results it is essentially moving one of the characters to the right further down your line. So where this might be helpful is, lets say you are typing fast and instead of going back and fixing a mistake you can go [LEFT] [LEFT] [LEFT] [CTRL]+[T] and that will fix your typing error. Now you can also move words left and right so you have [CTRL]+[SHIFT],[T] which will take the word you are on and replace it with the word to the right so we have the ability then to switch and swap the words that we are working with. So that’s [CTRL]+[SHIFT],[T] then you also have [ALT]+[SHIFT],[T] which will transpose the line that you are on. So that will move the line you are on down one and what ever line is below your current line will be replaced so just basically flip flops those around. So to do [ALT]+[SHIFT],[T] more then once you are moving that same line down your document.
Kick this Trick on DotNetKicks.com

1 comment(s)

  1. admin avatar

    I looked and there is no way to transpose lines up, they only go down, in native visual studio. Resharper has one though - keep reading...

    Two options in native VS, the first one sucks, to move lines up, instead of down with transpose.

    alt+shift+T, the up, up. <repeat />

    or with nothing selected on the line ...

    ctrl+X (cuts line) arrow to new location, and ctrl+V

    good ol' cut / paste

    with Resharper - use CTRL+ALT+SHIFT+ARROW

    this does ....

    single line movement

    attribute movement (left right)

    selection movement

    get / set movement

    method movement

    pretty much any code block cna be moved this way with Resharper.

    -=- Scott Cate


RSS Feeds

All Technology Posts

Scott Cate Main Blog Feed


Visual Studio Tricks Only Feed

@ScottCate on Twitter

Twitter @ScottCate

  • Today is a good day!
  • @blaken i already like @codesmithtools :)
  • @pacitpros is hosting a 2 day IT Pro Conference in San Francisco March 22-23rd, 2012 Tech Days http://t.co/2igpJikF
  • Can you help me get to a quick 25 likes for #Mykb on Facebook? http://t.co/0WSh2GdZ
  • Meeting Planner Meltdown via/ @EventDay evn.tc/xpXHnP #Engage365 #EventProfs