开发者

How do I get VS2008 to paste code without reformatting it (changing whitespace)?

I did some code alignment in the way I preferred, using vim--then tried to paste it into VS2008. Voila, 2008 decides to reformat it, removing all the whitespace I added to make some declarations开发者_JAVA百科 beautifully aligned.

Is there a way to have VS2008 either (A) paste without changing whitespace or (B) align the code as shown below?

public int              SomePropertyName   { get; set; }
public Nullable<string> SomeOtherProperty  { get; set; }
public Nullable<int>    YetAnotherProperty { get; set; }

which ends up like this when I paste it into VS2008:

public int SomePropertyName { get; set; }
public Nullable<string> SomeOtherProperty { get; set; }
public Nullable<int> YetAnotherProperty { get; set; }


Also, if you like the reformat most of the time, you can keep the option that Hans pointed out checked, and simply do a ctrl + z after you paste. It won't undo the paste, but it will undo the reformatting of your code. I prefer this method, since most of the time the reformat is a good thing. But, when I don't like the results, ctrl + z and it's all better.


It is an option. Tools + Options, Text Editor, C#, Formatting, "Automatically format on paste" check box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜