Move line Up/Down shortcut in Visual Studio 2012

后端 未结 9 1657
广开言路
广开言路 2021-01-30 15:59

In VS2010 I had a shortcut set up Alt+Up/Down to move lines of code up or down, just like I used to have in Eclipse in my Java days.

Now since Powe

9条回答
  •  别那么骄傲
    2021-01-30 16:17

    ReSharper's move up and move down shortcuts are smart - instead of just moving the current line (which can easily result in broken code), it will move the current statement up and down in the list of statements that make up the method body. This is much more powerful than just moving a single line of code.

    But this doesn't help you get your statement inside the if block. Here you need to do one of two things.

    Firstly, move the statement above the if block, then use Ctrl+Shift+Alt+Right to push it down in scope. The statement will now be inside the if block, and you can use up and down to move it around in there. You can also use Ctrl+Shift+Alt+Left to pull it up in scope, outside of the if block.

    Alternatively, you can put the text caret on the outside of the closing brace of the if block and use Ctrl+Shift+Alt+Down to move the brace down, stepping over following statements, including them inside the if block.

    These keys can do a lot more than just move a single statement. If you put the text caret on a method or class declaration, Up and Down will move the entire method or class declaration up and down. If you put the text caret in the parameter list of a method, Left and Right will rearrange individual parameters (and then Alt+Enter can invoke the Change Signature refactoring).

    More details in the help pages.

提交回复
热议问题