2010-07-20 43 views
6

我按照自己喜欢的方式做了一些代码对齐,使用vim - 然后尝试将它粘贴到VS2008中。 Voila,2008决定重新格式化它,除去所有我添加的空白,使一些声明精美对齐。如何让VS2008粘贴代码而不用重新格式化(改变空格)?

有没有办法让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; } 

回答

19

另外,如果你喜欢格式化的大部分时间,你可以保持汉斯指出选中的选项,只需粘贴后做一个CTRL + Z。它不会撤消粘贴,但会撤消对代码的重新格式化。我更喜欢这种方法,因为大多数情况下重新格式化是一件好事。但是,当我不喜欢这个结果时,ctrl + z并且它更好。

+0

+1,这是更好的解决方案。我会留下我的答案,嗯,参考。 – 2010-07-20 19:49:08

+0

+1,thx今天节省我的时间。 – sisdog 2011-05-10 19:20:29

5

一种选项。工具+选项,文本编辑器,C#,格式化,“粘贴时自动格式化”复选框。

+0

VS2017 - 工具>选项>文本编辑器> C#>代码样式>格式 – 2017-09-30 07:36:58

相关问题