Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's WebLog


My adventures embracing open source on CodePlex and at Microsoft

News

Did you know... How to transpose characters, words, and lines in the editor? - #021

Transpose example

  • Press Ctrl+T to transpose a character
  • Press Ctrl+Shift+T to transpose a word
  • Press Alt+Shift+T to transpose a line

In the above example (where the cursor is placed before the "is" on the commented line "now is the time"),

  • Pressing Ctrl+T will swap the 'i' and the previous space, creating  // nowi s the time
  • Pressing Ctrl+Shift+T will swap the "is" and "the", creating // now the is time
  • Pressing Alt+Shift+T will swap the current line with the line below it

Just out of curiosity, I'd love to know how people use this feature, so please leave me a comment. 

Technorati tags: ,
Posted: Thursday, August 23, 2007 3:00 AM by saraford

Comments

twoelfer said:

Sara,

never used this. now that i know of it - still don't think i will use it.

WM_SORRY

-thomas woelfer

# August 23, 2007 6:28 AM

Asztal said:

I really only use this feature for fun (or press it by accident)...

I sometimes open a C++ program, go to the first line, and hold Ctrl-Shift-T until it's all been transposed. The output vaguely looks like a program, and I find it quite amusing :)

I guess Alt-Shift-T might be useful to me. But then again, I'm already pretty used to the whole "Ctrl-L Up Home Ctrl-V" business.

# August 23, 2007 7:28 AM

Henning said:

I use Ctrl+T quite often, because wrong order of charactes is a common typo for me.

Sometimes I try Ctrl+T in Outlook or Word - then remember that it's not VS :-)

# August 23, 2007 8:32 AM

Sarath said:

Sara,

It's really cool functionality. I doubt in the real world people using this functionality. What do you think?

# August 23, 2007 9:17 AM

Jason Haley said:

# August 23, 2007 10:13 AM

Alex Dresko said:

Hello! I'm a fellow keyboard junkie and I've never understood how this feature could be useful. I never really find myself needing to swap lines/words/characters like this. The closest I come to that is using CTRL+L to copy the current line to the clipboard and CTRL+V to place is back where I want it.

I'll be interested to see if anyone else comments on this one.

# August 23, 2007 10:16 AM

codekaizen said:

I've used it to reorder arrays of numbers. It was also big help converting from ARGB color value sequences to BGRA.

Hm, now that I think of it, I could have used this in a macro.

# August 23, 2007 11:12 AM

saraford said:

Henning:  I'm really curious how you use this to fix typos.  Can you share what your keyboard sequence is?  Is it something like,

1. type "stirng"  

2. arrow left a few times to the cursor is between 'i' and 'r'

3. press Ctrl+T

now that i'm thinking about it, this might actuall have fewer keystrokes then backspacing the entire work (or deleting the entire word) then retyping it.  I'll give it a try for a day =)

# August 23, 2007 12:26 PM

GregM said:

I use line transpose a lot for reordering lines.  It can be a lot easier than cut/paste at times, especially since you don't have to select the text or get the cursor into the right place for the paste.  It's especially helpful when I have something on the clipboard that I want to keep there for a minute while I rearrange lines.

I don't remember ever using word transpose, but I do use character transpose.  I started using those back in my Emacs days, using a terminal, so no mouse, and it was a LOT faster than cut/paste.

# August 23, 2007 2:02 PM

Peter Ritchie said:

Has to be one of my most used features.  It's unfortunate that it isn't completely language-aware though.  Often, when I use Ctrl+Shift+T I expect it to swap C# statements.  For example:

new int[] {method(1), method("text")};

                   ^

Placing the cursor before the comma and pressing Ctrl+Shift+T I usually expect the result to be:

new int[] {method("text"), method(1)};

instead of

new int[] {method(method), 1("text")};

# August 23, 2007 3:12 PM

Mike Dunn said:

I remap Ctrl+T to Edit.QuickInfo to match VC6. I never transpose text often enough to bother learning the keystrokes for it, I just cut/paste as needed.

# August 23, 2007 6:24 PM

Richard Sim said:

I use word transpose fairly frequently - mostly for mathematical expressions that I've messed up. As has already been pointed out, it's also useful for reordering arrays, enums, and anything similar.

# August 24, 2007 2:05 AM

codekaizen said:

I'm with Peter Richie - if it were also more language aware (swap statements, statement blocks or even methods) it would be much more useful.

# August 24, 2007 11:32 AM

Erik said:

I have only used it by accident up till now :)

# August 26, 2007 3:05 PM

NickV said:

I use transpose line frequently. Useful when wrapping some code in an "If ... End If" statement which the editor autocompletes. Using transpose line is a quick way to move the End If down below the code you want to wrap.

# October 11, 2007 11:15 PM

Visual Studio 2008 ワンポイント said:

文字を入れ替えるには、 Ctrl + T キーを押します。 単語を入れ替えるには、 Ctrl + Shift + T キーを押します。 行を入れ替えるには、 Alt + Shift + T キーを押します

# July 13, 2008 11:46 PM

Секреты Visual Studio said:

Нажмите Ctrl+T для переноса символа, Нажмите Ctrl+Shift+T для переноса слова, Нажмите Alt+Shift+T для

# August 8, 2008 6:21 AM
New Comments to this post are disabled
Page view tracker