如何使VS2008在不重新格式化的情况下粘贴代码(更改空白)? [英] How do I get VS2008 to paste code without reformatting it (changing whitespace)?

查看:80
本文介绍了如何使VS2008在不重新格式化的情况下粘贴代码(更改空白)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用vim以我喜欢的方式进行了一些代码对齐,然后尝试将其粘贴到VS2008中。 Voila,2008年决定重新格式化它,删除我添加的所有空格以使某些声明精美地对齐。

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

当我将其粘贴到VS2008中时,最终结果如下:

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


解决方案

此外,如果您喜欢 ctrl + z 。它不会撤消粘贴,但是会撤消代码的重新格式化。我更喜欢这种方法,因为在大多数情况下,重新格式化是一件好事。但是,当我不喜欢结果时, ctrl + z 会更好。


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 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.

这篇关于如何使VS2008在不重新格式化的情况下粘贴代码(更改空白)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆