C# ide VS. VB ide

C

cj

I just stated writing some C# code and I notice it doesn't seem to go
back and correct indentation etc like it does in VB. I kinda liked that
in VB. If I removed an if else block it would reindent the code etc.
Is that something I can turn on or is it just not done in C#?
 
M

Morten Wennevik [C# MVP]

Hi,

No, this feature does not exist in C#. This is by design. To readjust
indentation you have to delete/add an end block } or end statement ; at a
higher level.
 
T

Tommy Holm Jakobsen

Hi.
I'm not sure that I understand your problem but if you are using Visual
Studio, you can reformat the whole document by pressing (CTRL+E, D) or
(CTRL+K, D).

Kind regards,
Tommy
 
M

Mick Wilson

I just stated writing some C# code and I notice it doesn't seem to go
back and correct indentation etc like it does in VB.  I kinda liked that
in VB.  If I removed an if else block it would reindent the code etc.
Is that something I can turn on or is it just not done in C#?

I don't know of a setting that does this, but there's a keyboard chord
that will do pretty much the same thing. As long as your code can be
parsed, you can hit ctrl-k -> ctrl-f to reformat whatever you have
selected. I often hit ctrl-a beforehand to do the whole file.

I prefer this to VB's autoformat. I've noticed sometimes that when vb
does its autoformatting trick, each of the indents/unindents are put
into the editor's undo history. Now, if want to ctrl-z over my last
few code changes, I have to back up over each of the formatting
changes that were put in. What I mentioned above might function the
same way (I've never noticed this problem in C#), but I at least have
more control over when I want it to happen.
 
I

Ignacio Machin ( .NET/ C# MVP )

I just stated writing some C# code and I notice it doesn't seem to go
back and correct indentation etc like it does in VB.  I kinda liked that
in VB.  If I removed an if else block it would reindent the code etc.
Is that something I can turn on or is it just not done in C#?

you can reformat the document using Ctrol K + Control D
 
M

Man T

you can reformat the document using Ctrol K + Control D

Sorry, what do you mean by
Control K + Control D?

Is that
Control + K
then
Control + D ?
 
C

cj2

So is their a menu way to do this? What does Control K do? Then
Control D? I mean is this just a complicated shortcut or does Control K
tell it select everything and Control D tell it to reformat or ..... I
don't see any menu items that list that combo and I don't see any that
list only ctrl k or ctrl d
 
Î

Αντώνης

Why don't you try it to see what does it do? In any case, this is
equivalent to CTRL + E, CTRL + D (Edit > Advanced > Format Document).
In addition:

Edit.FormatDocument
CTRL + K, CTRL + D
Applies the indenting and space formatting for the language as specified
on the Formatting pane of the language in the Text Editor section of the
Options dialog box.
(ms-help://MS.VSCC.v90/MS.msdnexpress.v90.en/dv_vssettings/html/754340bc-2db6-49c3-9de9-2deb008c1477.htm)



O/H cj2 έγÏαψε:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top