Posted By: VBJB | Oct 14th, 2006 @ 3:49 PM
page 1 of 1
Comments: 14 | Views: 5610

Why can't I code in Notepad or Emacs and open it up in Visual Studio 2005 and have everything lined up as it was when I coded it?

When I am coding I do not use the tab key. I only use the spacebar. I indent three spaces at a time when code needs to be indented. It bugs me everything looks great in Notepad/Emacs, but when I open it up in Visual Studio everything is misaligned.

Is there anything I can do?

If you really only use spaces then it should line up. Can you give a screenshot of what is happening?
Sven Groot wrote:
If you really only use spaces then it should line up. Can you give a screenshot of what is happening?


>
SecretSoftware wrote:
Click on the HTML Page Formater, it will align everything ok.


Use the "Show visual-space" option to see whitespace characters.
Click on the HTML Page Formater, it will align everything ok.


Its in the ToolBar >HTML Source Editor >> Format Whole Document button.
W3bbo wrote:

SecretSoftware wrote: Click on the HTML Page Formater, it will align everything ok.


Use the "Show visual-space" option to see whitespace characters.


I use Visual Glyphs for word wrap. Did you mean Virtual Space?

I think that there is a missing feature in the VS2005 code Editor. The feature is a magnifing glass. Like we have in IE7, you can magnify the page or make it smaller. So as to allow me to have a bird-eye view of the code to help visualize the overall code in your mind. I do this by changing the screen resolution to a higher settings. But I prefered if there was a magnifier to set the code view.

I wounder if Virtualization would be applied in the next release of VS, so that redrawing of win forms would be fast and efficient. Somehow things seem more stable , from redrawing point, when I am at a higher screen resolution. Weird eh?

VBJB wrote:


Why can't I code in Notepad or Emacs and open it up in Visual Studio 2005 and have everything lined up as it was when I coded it?

When I am coding I do not use the tab key. I only use the spacebar. I indent three spaces at a time when code needs to be indented. It bugs me everything looks great in Notepad/Emacs, but when I open it up in Visual Studio everything is misaligned.

Is there anything I can do?



check the FONT used in each app...

also the tabs and indent settings....
SecretSoftware wrote:
Click on the HTML Page Formater, it will align everything ok.


Its in the ToolBar >HTML Source Editor >> Format Whole Document button.


When I bring the toolbar up the Format Whole Document is grayed out.
W3bbo wrote:

SecretSoftware wrote: Click on the HTML Page Formater, it will align everything ok.


Use the "Show visual-space" option to see whitespace characters.


I am definitely seeing some tabs. I guess Emacs must be putting them in. It’s weird between Emacs and Notepad the format is consistent, but VS 2005 it is different.

Emacs probably uses a tab width of 8 like notepad so it looks the same, while Visual Studio uses 4 (by default).

Also, if you have the convert tabs to spaces option selected in VS, then removing and retyping the last closing brace in the code will usually get VS to reformat everything inside those braces including replacing the tabs with spaces.

By the way, I haven't used emacs much (I prefer vim), but I assume it would probably have a configuration option somewhere like VS and vim do to tell it to use spaces instead of tabs.  Most good editors do have an option like that (and apparently emacs is a good editor Wink)
Visual studio has its own auto-aligning code with works with 4 spaces (not three).

The problem is that the code you've written isn't valid code, there's missing comma's and suchlike. This confuses the VS auto-aligner, and you end up with misaligned code. (at least, thats what i think is happening)

Fix the code errors and then you're code will align correctly. To force VS to realign the code, just remove and add in the "closing" curly brace at the end of methods, and that method will realign etc
alanmc wrote:
Visual studio has its own auto-aligning code with works with 4 spaces (not three).

The problem is that the code you've written isn't valid code, there's missing comma's and suchlike. This confuses the VS auto-aligner, and you end up with misaligned code. (at least, thats what i think is happening)

Fix the code errors and then you're code will align correctly. To force VS to realign the code, just remove and add in the "closing" curly brace at the end of methods, and that method will realign etc

the indent is a user option, default is 4 but can be changed, I use 3 in my code.


a quick look at the code seems ok. I think vs just did not re-format part of it the way he wants it.


BTW: there are settings where you can "teach" vs how to re-format some things the way you want them.

I think what I saw was his printf() that uses 2 lines was not the way he wanted it
the continued line was out-dented and not lined up with the first line's quoted text.
alanmc wrote:
Visual studio has its own auto-aligning code with works with 4 spaces (not three).

The problem is that the code you've written isn't valid code, there's missing comma's and suchlike. This confuses the VS auto-aligner, and you end up with misaligned code. (at least, thats what i think is happening)

Fix the code errors and then you're code will align correctly. To force VS to realign the code, just remove and add in the "closing" curly brace at the end of methods, and that method will realign etc


This code compiles both in gcc and VS. The syntax is fine. I am only allowed to have an 80 character width that is why it is broken up.
page 1 of 1
Comments: 14 | Views: 5610