简体   繁体   中英

Visual Studio code formatter

I'm using Visual Studio 2008 for doing work in C# and JavaScript (AJAXy stuff).

Here's my issue -- I love Eclipse and especially the code formatted (Ctrl-Shift-F). Visual Studio's Ctrl-k, Ctrl-d, really sucks in comparison, especially for javascript.

Is there a way to get VS to behave like the IDE that I miss?

Go into Tools | Options | Text Editor and edit the language specific settings to you're liking. Ctrl-K, Ctrl-D honors these settings, so you can make the code formatter working the way you want. There are a ton of options you can change (bracket positioning, spacing, indenting, etc.).

I use the great Resharper plugin to format my C# code. Lots of settings to change to format your code to your liking. Can even make one coding standard with Resharper to be used by all your programmers.

As for key bindings, can change those in your options.

以下是visual studio的解决方法:我只需将扩展名重命名为.css,右键单击文档内部并选择“格式化文档”并将其重命名为.js,格式非常好。

go to options > environment > keyboard, find the command Edit.FormatDocument and bind that to ctrl + shift + f

EDIT: Misread, you can configure how VS formats in options > text editor > (document type).

don't know if you can get it exactly as how eclipse does, but that's where you set your preferences.

I have not tried but Resharper has lot of formatting and coding related nice stuff. May be you can find something useful there, and you may start loving VS as well.

Note: Resharper on VS2005 was kind of sluggish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM