问题
Ctrl K + D in a Visual Studio 2010 Sharepoint project is not working in some files as they contain paths to some resources (masterpageurl/images/js/css classnames) that get generated at runtime.
How do I make VS to "ignore" checking if these resources exist or not?
回答1:
Code formatting doesn't work in multi-line arrays :
int[] ok={ 1 , 2, 3 };
int[] ko={
1 ,
2,
3
};
use Ctrl K + D
int[] ok = { 1, 2, 3 }; // nice formatting
int[] ko ={
1 ,
2,
3
}; // nothing changed :(
回答2:
Check for other errors in the same file. If there are errors, it will not format the document until they are fixed. In order to help you during design time, you can create dummy resources, point to those, then change the references at runtime to the dynamically generated content.
回答3:
You can choose from the following menus:
Tools -> Options -> Text Editor -> <Pick your language>
or use
"All Languages" -> Tabs -> Indenting -> Smart
Also, my own preference is to change the tab section to "Insert Spaces". this way, when you open the visual studio files in a different editor, such as notepad, the formatting will be the same.
回答4:
CTRL-K-D will always format. I left out a semicolon and because of an error as specified in the above posts the formatting didn't work. Make sure that there are no errors and the formatting will always work. An easy way to spot an error is to look on the right hand sidebar for any red dots.
来源:https://stackoverflow.com/questions/9706908/visual-studio-ctrl-k-d-code-formatting-not-working