Did you know... How to transpose characters, words, and lines in the editor? - #021
- 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: VS2005Tip, VS2008Tip
Comments
Anonymous
August 22, 2007
Sara, never used this. now that i know of it - still don't think i will use it. WM_SORRY -thomas woelferAnonymous
August 22, 2007
The comment has been removedAnonymous
August 23, 2007
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 :-)Anonymous
August 23, 2007
Sara, It's really cool functionality. I doubt in the real world people using this functionality. What do you think?Anonymous
August 23, 2007
The comment has been removedAnonymous
August 23, 2007
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.Anonymous
August 23, 2007
Henning: I'm really curious how you use this to fix typos. Can you share what your keyboard sequence is? Is it something like,
- type "stirng"
- arrow left a few times to the cursor is between 'i' and 'r'
- 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 =)
Anonymous
August 23, 2007
The comment has been removedAnonymous
August 23, 2007
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")};Anonymous
August 23, 2007
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.Anonymous
August 23, 2007
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.Anonymous
August 24, 2007
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.Anonymous
August 26, 2007
I have only used it by accident up till now :)Anonymous
October 11, 2007
The comment has been removedAnonymous
July 13, 2008
文字を入れ替えるには、 Ctrl + T キーを押します。 単語を入れ替えるには、 Ctrl + Shift + T キーを押します。 行を入れ替えるには、 Alt + Shift + T キーを押しますAnonymous
August 07, 2008
Нажмите Ctrl+T для переноса символа, Нажмите Ctrl+Shift+T для переноса слова, Нажмите Alt+Shift+T дляAnonymous
December 04, 2008
本篇包括tip21-tip30http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-3.html#021、调整字符、...Anonymous
December 07, 2008
本篇包括tip21-tip30 http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-3.html #021、调整...