I am using visual studio 2013, I am using an extension called "Code Alignment". After I apply the alignment and try to beautify the code, the visual studio removes the alignment.
I already checked the options in:
Option > Text Editor:
Tabs
Keep tabs
Do you have a solution for this?
ie:
before formatting:
var previousLowAddress = new string[1];
var previousMedAddresses = new string[1];
var previousHighAddresses = new string[1];
after visual studio formatting:
var previousLowAddress = new string[1];
var previousMedAddresses = new string[1];
var previousHighAddresses = new string[1];
Most likely, the problem is the font you are using is not "monospaced". This means different characters can take different amount of space, which will break the math the CodeAlignment plugin will do for you.
Try changing the Text Editor font to a monospaced type, such as "Consolas".
I tested this locally using Consolas and Microsoft YaHei UI fonts. As expected, the monospaced font (consolas) shows the correct alignment, and the Proportional font (Microsoft YaHei UI) does not.
VS has auto formatting enabled by default for c#. The options are in Text Editor\C#\Formatting.
You may need to disable all option in these category.
The productivity power tools extension also has a feature which formats the document on save. So if you use these extension you may disable the feature.
The built-in c# auto formatting honors indenting assignments, but if you try to indent round brackets/operators (as code alignment does), the extra whitespace will be removed by formatting.
Related
There appears to be no option for automatic formatting, it slightly irritates me. Perhaps I have OCD:
private void someFunc() {
}
// I want
private void someFunc(){
}
I have tried looking in |options > text editor > C# > code style > formatting| ... to no avail.
In c# formatting is no entirely automatic. You need to press ctrl+k;ctrl+e to format file.
For C# code files, Visual Studio 2019 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl+K, Ctrl+E) to apply code styles from an EditorConfig file or from the Code Style options page.
Use instruction from here to setup your style
But, if there is a space or no space - you must set in your style setting.
I have a problem with underline text after press a button in Visual Basic. I'm using Visual Studio 2010 and I red in tutorial that in button method I have to use for example:
lbltext.FontUnderline = True
But I don't have variable "FontUnderline". Of course I was trying to find other variable or function to do this but without success. Anyone know how to do this in Visual Studio?
An inline answer looks like this:
Me.lbltext.Font = New Font(lbltext.Font, FontStyle.Underline)
This would save multiple lines of code.
Or the old way of doing it was to instance a new font
Font standardFont = new Font(lblText.Font)
Font underFont = new Font(standardFont,FontStyle.Underline)
Then just set the Font property of the relevant controls to the one you want.
Took the example of #Tony Hopkinson and added some small changes to make this work for VB.NET
So this is the syntax for VB.NET
Dim standardFont As Font = lblExportDate.Font
Dim underFont As New Font(standardFont, FontStyle.Underline)
Me.lblExportDate.Font = underFont
I think you are missing a dot here.
It should be lbltext.Font.Underline = true
I wish to disable all code formatting in Visual Studio 2010, with the intention of selectively switching options back on as I see fit.
Currently I have a specific problem that refuses to go away; When I add the final brace in the code block below, Visual Studio 2010 reformats the code for the entire switch statement above that point, placing each line against the margin (removes leading whitespace on each line). I've switched off every setting in Tools/Options/C#/Formatting to no avail. Is there an overriding 'Disable all formatting' option? Thanks.
switch(fractionalDigits)
{
case 0:
if(significand > 107374u)
{
if(truncateRange)
{
significand = 1073741823u;
}
else
{
result = FixedPointDecimal.Null;
return false;
}
}
else
{
UPDATE: The specific problem above was caused by additional formatting options being added by the Power Tools. The additional formatting options seem to interact with the built in logic an odd way.
Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels
You could try the following:
Create a color theme with nearly no color. So you could readjust each code elements color step by step.
You can use the following tool to generate a no color theme:
Theme generator
Set the constrast to the left and main and foreground color to white.
I am trying to change the color of the http links inside string literals in Visual Studio 2010, but neither String, not Literal doesn't control the color of them. They still appear blue.
For instance:
"http://mylink.com"
" characters appear in the color I set, but http://mylink.com still stays the same color which is blue.
What item in the Fonts and Colors customization of VS control this?
The item you are looking for is "URL Hyperlink". Changing this will update the values in your code.
Faced problem while setting background color for any element in Visual Studio 2010 editor. Selection color doesn't override this background color. So then it's very inconvenient to work with selections in editor.
Case when only string literal is selected it's almost impossible to distinguish colors and see what part of string is selected.
Is there any possibility to fix the problem by changing some options? Or it's a Visual Studio bug?
This is new VS2010 behavior which unfortunately is deliberate. However, Noah Richards (from the editor team) has written a couple of extensions that help mitigate the new behavior:
The first is an extension that draws a border around the selection (the main feature of the extension is a gradient background, but the border is what makes it really useful for me).
Second is an extension to change Selection Foreground color.