Visual studio CTRL+SHIFT+T transpose - what does it do?
Since CTRL-T swaps the two characters on either side of the cursor, the opposite of it is ...
wait for it ...
CTRL-T
:-)
CTRLSHIFTT transposes the two words after the cursor.
What it's doing to your block seems rather bizarre. It appears to doing it to multiple parts of each line. My only advice would be (as the doctor said to the patient who complained it hurts when banging their head against a wall): Don't do that.
As others have pointed out, the two words following the cursor are transposed, and the cursor is placed after the words that have been transposed. However, Visual Studio 2010 at least appears to ignore commas and other punctuation when considering "words." One utility of this, then, is that you can reorder something like an enum. For instance,
typedef enum myEnum
{
ThingOne,
ThingThree,
ThingTwo
};
Put the cursor somewhere near ThingThree and press CtrlShiftT to get:
typedef enum myEnum
{
ThingOne,
ThingTwo,
ThingThree
};
This could be a good thing if you decide that a different order for your enums is better. You can also use this to help idiot-proof comparisons and/or quickly and easily format them to a better coding standard.
if ( ptr == NULL ) { /* stuff */ }
is considered bad (never mind that having an "if" on its own line is also bad) since you could easily write (or read) "ptr = NULL" by accident. You're better off with
if ( NULL == ptr ) { /* stuff */ }
So, if you did it wrong the first time, just select the offending expression and...CtrlShiftT to the rescue!
...Yeah, okay, so this thing isn't that useful.
Edit: Hmm, I should add that the behavior is a little weirder when your cursor is placed immediately before a punctuation symbol (such as a left-parenthesis), hence the weird result you got when you repeatedly hit CtrlShiftT on your code snippet. It seems to just swap any whitespace-terminated string after the cursor with the next alphanumeric "word," skipping over any punctuation symbols in between. The result is often difficult to read, though, so I'm not going to claim that's the exact pattern.
According to this website:
Transposes the two words that follow the cursor. (For example, |End Sub would be changed to read Sub End|.)
The only question that remains is probably: WHY?? Well it might become handy when you have a block of code lines where variables are assigned values. (For example Load/Save) In the opposite function, you want to do the opposite assignment, maybe this shortcut can be used in such a situation...