C# Visual Studio 中的缩进快捷方式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9012055/
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
Indentation shortcuts in Visual Studio
提问by RBA
I'm new to Visual Studio 2010 and C#. How can I indent the selected text to left/right by using shortcuts?
我是 Visual Studio 2010 和 C# 的新手。如何使用快捷方式将所选文本向左/向右缩进?


In the Delphi IDE the equivalents are Ctrl+Shift+Iand Ctrl+Shift+U
在 Delphi IDE 中,等价物是Ctrl+ Shift+I和Ctrl+ Shift+U
采纳答案by Mike Christensen
Taband Shift+Tabwill do that.
Tab和Shift+Tab会这样做。
Another cool trick is holding down ALTwhen you select text, it will allow you to make a square selection. Starting with VS2010, you can start typing and it will replace the contents of your square selection with what you type. Absolutely awesome for changing a bunch of lines at once.
另一个很酷的技巧是ALT在您选择文本时按住,它可以让您进行方形选择。从 VS2010 开始,您可以开始输入,它会用您输入的内容替换正方形选择的内容。一次更改一堆行绝对很棒。
回答by Bassam Mehanni
You can just use Taband Shift+Tab
你可以只使用Tab和Shift+Tab
回答by Giovanni Galbo
Tab to tab right, shift-tab to tab left.
Tab 到 Tab 右,shift-tab 到 Tab 左。
回答by Tony Hopkinson
Ctrl-K, Ctrl-D
Will just prettify the entire document. Saves a lot of messing about, compared to delphi.
Ctrl- K, Ctrl-D
只会美化整个文档。与delphi相比,节省了很多麻烦。
Make sure to remove all indents by first selecting everything with Ctrl+Athen press Shift+Tabrepeatedly until everything is aligned to the left. After you do that Ctrl+K, Ctrl+Dwill work the way you want them to.
首先用Ctrl+选择所有内容,A然后 重复按Shift+Tab直到所有内容都向左对齐,确保删除所有缩进 。在你这样做之后 Ctrl+ K,Ctrl+D会按照你想要的方式工作。
You could also do the same but only to a selection of code by highlighting the block of code you want to realign, aligning it to the left side (Shift+Tab) and then after making sure you've selected the code you want to realign press Ctrl+K, Ctrl+Forjust right click the highlighted code and select "Format Selection".
您也可以通过突出显示要重新对齐的代码块,将其与左侧 ( Shift+ Tab)对齐,然后在确保已选择要重新对齐的代码后按Ctrl+ K, Ctrl+F或只需右键单击突出显示的代码并选择“格式选择”。
回答by Mausimo
If you would like nicely auto-formatted code. Try CTRL+ A+ K+ F. While holding down CTRLhit a, then k, then f.
如果您想要很好的自动格式化代码。试试CTRL+ A+ K+ F。一边按住CTRL打a,然后k,然后f。
回答by Schreinbo
Just hit Tab to push it over or on the menu bar Edit --> Advanced --> Format Selection and that will auto indent, the keyboard shortcut is also shown in the menu.
只需点击 Tab 将其推到菜单栏上或在菜单栏编辑 --> 高级 --> 格式选择,这将自动缩进,键盘快捷键也显示在菜单中。
回答by Jorgesys
Visual studio's smart indenting does automatically indenting, but we can select a block or all the code for indentation.
Visual Studio 的智能缩进会自动缩进,但是我们可以选择一个块或所有代码进行缩进。
Select all the code: Ctrl+a
Use either of the two ways to indentation the code:
Shift+Tab,
Ctrl+k+f.
选择所有代码:Ctrl+a
使用以下两种方法之一来缩进代码:
Shift+ Tab,
Ctrl+ k+ f。
回答by user3029478
If the move-left and move-right shortcuts do not appear on your screen, click at the rightmost position of your toolbar at the top. You should get "Add or Remove Buttons." Add the buttons "decrease line indent" and "increase line indent"
如果屏幕上没有出现左移和右移快捷方式,请单击顶部工具栏最右侧位置的 。您应该得到“添加或删除按钮”。添加按钮“减少行缩进”和“增加行缩进”

