none
Tabs after code changes into spaces

    Question

  • I have Visual Studio Community 2015 and if I put tabs after code and then format the document, these tabs are changed into spaces.

    I usually place a comments at the right side of the document to take notice of them later. I do these with tabs so each of them line up perfectly. But any kind of formatting changes these tabs into spaces (even if I copy and paste the line).

    The "Tabs" in Tools/Options has no effect on this. It is set to keep tabs, but that work only on tabs before any code, not after it.

    The key point here is that Visual Studio is changing my code in unwanted ways and I'd like to know how to disable this particular thing.

    Thursday, September 15, 2016 2:52 PM

Answers

All replies

  • Hi Qualdan,

    Thanks for your post.

    For your question:

    >>these tabs are changed into spaces.

    The tab in essence is equal to 4 spaces by default.

    >>The "Tabs" in Tools/Options has no effect on this.

    Under the Formatting option, there are some settings for Spacing.

    >>The "Tabs" in Tools/Options has no effect on this. It is set to keep tabs, but that work only on tabs before any code, not after it.

    So what you want is to keep tabs after the code, right?

    You may go to Formatting>Spacing to set the corresponding spacing setting as you want.

    Best Regards, 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.


    Friday, September 16, 2016 8:22 AM
    Moderator
  • Thank you for your answer.

    Unfortunately the Formatting > Spacing doesn't seem to have the option that I need.

    I have included an image to illustrate what I want to happen. The first row of "AnotherFunction();" has tabs after it, before the comment. The second row is what happens automatically when formatting the document, when these tabs are changed into spaces.

    Code example

    Monday, September 19, 2016 1:09 PM
  • Use Editorconfig add-on.

    Generally, avoid tabs because they make trouble. Storage is cheap now.

    --pa


    Monday, September 19, 2016 1:17 PM
  • The fact that Visual Studio changes the code in unwanted ways on format/paste shouldn't be something that is fixed with an add-on.

    And the usage of tabs is a matter of preference, since they don't "make trouble". They allow each individual on a team to change the indentation of code to their liking, which you can't do with spaces. It has nothing to do with storage.

    Sunday, September 25, 2016 11:29 AM
  • Hi Qualdan,

    I did a research about this, but currently there is not such a setting that could change this Tab modify.

    But You could submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com, Microsoft engineers will evaluate them seriously. Thanks for your understanding. After you submit the feedback, you can post the link here which will be beneficial for other members with the similar issue. And I will help you to vote it.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Tuesday, September 27, 2016 9:20 AM
    Moderator
  • I created a feedback item on Microsoft Connect and it can be found at:

    https://connect.microsoft.com/VisualStudio/feedback/details/3106612/code-changes-tabs-into-spaces-on-paste


    Wednesday, October 12, 2016 4:12 PM
  • Hi Qualdan,

    Thanks for sharing the link here, I have voted it, please mark your replay as the answer, So it would be helpful for other members who get the same issue as yours to research and find the answer directly, and I could close this case.

    Have a nice day.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Thursday, October 13, 2016 1:11 AM
    Moderator