In eclipse there is a shortcut Ctrl+Shift+F that re-indents code and fixes comments and blank lines. Is there an equivalent for Visual Studio 2010?
在eclipse中,有一个快捷键Ctrl+Shift+F,可以重新缩进代码并修复注释和空行。在Visual Studio 2010中是否有类似的功能?
9 个解决方案
#1
585
Visual Studio WITH C# KEY BINDINGS
使用c#键绑定的Visual Studio。
To answer the specific question, in C# you are likely to be using the C# keyboard mapping scheme, which will use these hotkeys by default:
为了回答这个特定的问题,在c#中,您可能会使用c#键盘映射方案,默认情况下将使用这些热键:
Ctrl+E, Ctrl+D to format the entire document.
Ctrl+E, Ctrl+D来格式化整个文档。
Ctrl+E, Ctrl+F to format the selection.
Ctrl+E, Ctrl+F来格式化选区。
You can change these in Tools > Options > Environment -> Keyboard (either by selecting a different "keyboard mapping scheme", or binding individual keys to the commands "Edit.FormatDocument" and "Edit.FormatSelection").
您可以在>选项>环境->键盘上更改这些选项(通过选择不同的“键盘映射方案”,或将单个键绑定到命令“编辑”)。FormatDocument”和“Edit.FormatSelection”)。
If you have not chosen to use the C# keyboard mapping scheme, then you may find the key shortcuts are different. For example, if you are not using the C# bindings, the keys are likely to be:
如果您没有选择使用c#键盘映射方案,那么您可能会发现关键的快捷方式是不同的。例如,如果您没有使用c#绑定,那么键很可能是:
Ctrl + K + D (Entire document)
Ctrl + K + D(整个文档)
Ctrl + K + F (Selection only)
Ctrl + K + F(只选)
To find out which key bindings apply in YOUR copy of Visual Studio, look in the Edit > Advanced menu - the keys are displayed to the right of the menu items, so it's easy to discover what they are on your system.
要找出在Visual Studio的副本中应用了哪些键绑定,请查看编辑>高级菜单——这些键显示在菜单项的右边,因此很容易发现它们在您的系统上的内容。
(Please do not edit this answer to change the key bindings above to what your system has!)
(请不要编辑这个答案,将上面的键绑定更改为您的系统所拥有的!)
#2
75
Ctrl + K + D (Entire document)
Ctrl + K + D(整个文档)
Ctrl + K + F (Selection only)
Ctrl + K + F(只选)
#3
23
try Ctrl + K + D ("don't leave Ctrl in between")
尝试Ctrl + K + D(“不要在中间保留Ctrl”)
#4
18
Yes, you can use the two-chord hotkey (Ctrl+K, Ctrl+F if you're using the General profile) to format your selection.
是的,你可以使用两和弦热键(Ctrl+K, Ctrl+F,如果你使用一般的配置文件)来格式化你的选择。
Other formatting options are under Edit » Advanced, and like all VS commands, you can set your own hotkey via Tools » Options » Environment » Keyboard (the format selection command is called Edit.FormatSelection
).
其他的格式化选项都在“编辑”中,就像所有的VS命令一样,你可以通过工具»选项»环境»键盘来设置你自己的热键(格式选择命令被称为Edit. formatselection)。
Formatting doesn't do anything with blank lines, but it will indent your code according to some rules that are usually slightly off from what you probably want.
格式不需要空白行,但是它会根据一些规则缩进你的代码,这些规则通常与你可能想要的稍微偏离。
#5
15
resharper - Ctrl + Alt + F
resharper - Ctrl + Alt + F。
VS 2010 - Ctrl + K, Ctrl + D
VS 2010 - Ctrl + K, Ctrl + D。
#6
6
To align the text in proper format =
以适当的格式对齐文本=。
Ctrl + K + D for front end pages like .aspx
or .cshtml
像。aspx或。cshtml这样的前端页面的Ctrl + K + D。
Ctrl + K + F for .cs
page
Ctrl + K + F。
but note that press all buttons in sequence accordingly..
但是请注意按顺序按下所有按钮。
#7
5
Format the entire document: ctrl + k + d
格式化整个文档:ctrl + k + d。
#8
2
Select all document and press Ctrl + E + D
选择所有文档并按Ctrl + E + D。
#9
0
Format for selection:
格式选择:
ctrl + k + f
ctrl + k + f。
format for entire document:
整个文档的格式:
ctrl + k + d
ctrl + k + d。
#1
585
Visual Studio WITH C# KEY BINDINGS
使用c#键绑定的Visual Studio。
To answer the specific question, in C# you are likely to be using the C# keyboard mapping scheme, which will use these hotkeys by default:
为了回答这个特定的问题,在c#中,您可能会使用c#键盘映射方案,默认情况下将使用这些热键:
Ctrl+E, Ctrl+D to format the entire document.
Ctrl+E, Ctrl+D来格式化整个文档。
Ctrl+E, Ctrl+F to format the selection.
Ctrl+E, Ctrl+F来格式化选区。
You can change these in Tools > Options > Environment -> Keyboard (either by selecting a different "keyboard mapping scheme", or binding individual keys to the commands "Edit.FormatDocument" and "Edit.FormatSelection").
您可以在>选项>环境->键盘上更改这些选项(通过选择不同的“键盘映射方案”,或将单个键绑定到命令“编辑”)。FormatDocument”和“Edit.FormatSelection”)。
If you have not chosen to use the C# keyboard mapping scheme, then you may find the key shortcuts are different. For example, if you are not using the C# bindings, the keys are likely to be:
如果您没有选择使用c#键盘映射方案,那么您可能会发现关键的快捷方式是不同的。例如,如果您没有使用c#绑定,那么键很可能是:
Ctrl + K + D (Entire document)
Ctrl + K + D(整个文档)
Ctrl + K + F (Selection only)
Ctrl + K + F(只选)
To find out which key bindings apply in YOUR copy of Visual Studio, look in the Edit > Advanced menu - the keys are displayed to the right of the menu items, so it's easy to discover what they are on your system.
要找出在Visual Studio的副本中应用了哪些键绑定,请查看编辑>高级菜单——这些键显示在菜单项的右边,因此很容易发现它们在您的系统上的内容。
(Please do not edit this answer to change the key bindings above to what your system has!)
(请不要编辑这个答案,将上面的键绑定更改为您的系统所拥有的!)
#2
75
Ctrl + K + D (Entire document)
Ctrl + K + D(整个文档)
Ctrl + K + F (Selection only)
Ctrl + K + F(只选)
#3
23
try Ctrl + K + D ("don't leave Ctrl in between")
尝试Ctrl + K + D(“不要在中间保留Ctrl”)
#4
18
Yes, you can use the two-chord hotkey (Ctrl+K, Ctrl+F if you're using the General profile) to format your selection.
是的,你可以使用两和弦热键(Ctrl+K, Ctrl+F,如果你使用一般的配置文件)来格式化你的选择。
Other formatting options are under Edit » Advanced, and like all VS commands, you can set your own hotkey via Tools » Options » Environment » Keyboard (the format selection command is called Edit.FormatSelection
).
其他的格式化选项都在“编辑”中,就像所有的VS命令一样,你可以通过工具»选项»环境»键盘来设置你自己的热键(格式选择命令被称为Edit. formatselection)。
Formatting doesn't do anything with blank lines, but it will indent your code according to some rules that are usually slightly off from what you probably want.
格式不需要空白行,但是它会根据一些规则缩进你的代码,这些规则通常与你可能想要的稍微偏离。
#5
15
resharper - Ctrl + Alt + F
resharper - Ctrl + Alt + F。
VS 2010 - Ctrl + K, Ctrl + D
VS 2010 - Ctrl + K, Ctrl + D。
#6
6
To align the text in proper format =
以适当的格式对齐文本=。
Ctrl + K + D for front end pages like .aspx
or .cshtml
像。aspx或。cshtml这样的前端页面的Ctrl + K + D。
Ctrl + K + F for .cs
page
Ctrl + K + F。
but note that press all buttons in sequence accordingly..
但是请注意按顺序按下所有按钮。
#7
5
Format the entire document: ctrl + k + d
格式化整个文档:ctrl + k + d。
#8
2
Select all document and press Ctrl + E + D
选择所有文档并按Ctrl + E + D。
#9
0
Format for selection:
格式选择:
ctrl + k + f
ctrl + k + f。
format for entire document:
整个文档的格式:
ctrl + k + d
ctrl + k + d。