Visual Studio 中 Eclipse 的 ALT+UP/DOWN(移动线)的等价物是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4526715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?
提问by Roberto
In Eclipse, selecting a line and pressing Alt+ ↑/↓will move the line up and down, a quick way to avoid copy&paste. Is there an equivalent in Visual Studio?
在 Eclipse 中,选择一行并按Alt+ ↑/↓将上下移动该行,这是避免复制和粘贴的快速方法。Visual Studio 中是否有等价物?
回答by Kevin Aenmey
In Visual Studio 2013 and later, this functionality is built in. ALT + UP/DOWN will move a line up or down.
在 Visual Studio 2013 及更高版本中,此功能是内置的。ALT + UP/DOWN 将向上或向下移动一行。
If you need this functionality in VS2012 (works with VS2010 too), take a look at the MoveLine Visual Studio Extensionor the Productivity Power Toolssuite.
如果您在 VS2012 中需要此功能(也适用于 VS2010),请查看MoveLine Visual Studio Extension或Productivity Power Tools套件。
回答by Omer Raviv
ReSharper's Ctrl+ Shift+ Alt+ ↑/↓/←/→is even more powerful - when on the beginning of the line, it will move the entire line, but can also be used to move entire methods, change the order of parameters, etc.
ReSharper的Ctrl+ Shift+ Alt+ ↑/ ↓/ ←/→更是如虎添翼-当上线之初,它会移动整条生产线,但也可以用于移动整个方法,更改参数的顺序,等等。
回答by Drealmer
This is now working out of the box with Visual Studio 2013, same way as in Eclipse.
这现在可以在 Visual Studio 2013 中开箱即用,与 Eclipse 中的方式相同。
回答by Andreas Bergstr?m
In Visual Studio 2013 and later, you can move lines up and down using Alt+ ↑/ Alt+ ↓. Unfortunately this will not adjust the indentation if you move between blocks, as of today only ReSharper (and all other IDE's by Jetbrains including Rider) can help you with that.
在 Visual Studio 2013 及更高版本中,您可以使用Alt+ ↑/ Alt+上下移动行↓。不幸的是,如果您在块之间移动,这不会调整缩进,截至今天,只有 ReSharper(以及 Jetbrains 的所有其他 IDE,包括 Rider)可以帮助您。
To move entire blocks of code around you can move the cursor to its head and press Ctrl+ mtwice fast to collapse it, and then use the command above to move it around.
要移动整个代码块,您可以将光标移动到其头部并快速按Ctrl+m两次以折叠它,然后使用上面的命令移动它。
Here is a neat reference to all default keyboard shortcutsin different versions of Visual Studio.
这是对不同版本的 Visual Studio 中所有默认键盘快捷键的简洁参考。
回答by Umut Sun
For me in Visual Studio 2019 it comes default closed.
对于我在 Visual Studio 2019 中,它默认关闭。
For open it:
打开它:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesUp, click "Press shortcut keys" input and press Alt + Up (or whatever you want for it). And the other one is Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down (or whatever you want for it).
工具 -> 选项 -> 键盘然后选择Edit.MoveSelectedLinesUp,单击“按快捷键”输入并按 Alt + Up(或任何您想要的)。另一个是Edit.MoveSelectedLinesDown,单击“按快捷键”输入并按 Alt + Down(或任何你想要的)。
回答by eFloh
With the VSCommands extension, you have exactly that keyboard shortcut. And, by the way, a Stack OVerflow notification toolbar :)
有了 VSCommands 扩展,你就有了那个键盘快捷键。而且,顺便说一下,一个堆栈溢出通知工具栏:)