我使用vim以我喜欢的方式进行了一些代码对齐 - 然后尝试将其粘贴到VS2008中。 Voila,2008决定重新格式化它,删除我添加的所有空格,使一些声明完美对齐。
有没有办法让VS2008(A)粘贴而不改变空格或(B)对齐代码,如下所示?
public int SomePropertyName { get; set; }
public Nullable<string> SomeOtherProperty { get; set; }
public Nullable<int> YetAnotherProperty { get; set; }
当我将其粘贴到VS2008中时会以此结束:
public int SomePropertyName { get; set; }
public Nullable<string> SomeOtherProperty { get; set; }
public Nullable<int> YetAnotherProperty { get; set; }
答案 0 :(得分:21)
此外,如果您喜欢大部分时间重新格式化,您可以保留Hans指出选中的选项,并在粘贴后只需执行 ctrl + z 。它不会撤消粘贴,但会撤消重新格式化代码。我更喜欢这种方法,因为大多数时候重新格式化是一件好事。但是,当我不喜欢这些结果时, ctrl + z 就会更好。
答案 1 :(得分:5)
这是一个选择。工具+选项,文本编辑器,C#,格式化,“粘贴时自动格式化”复选框。