AtmelStudio formating lost on cut/paste

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I have looked in the forum and not found an answer to this question.... apologies in advance if it is there and I have missed it.

 

AtmelStudio periodically changes the formatting of my code. It happens at least when I cut/paste code but possible also at other times (that I can't describe). I know about the VA Snippet editor and think I am using it correctly.

 

For example if I have code like

switch(var)
{
    case value1:
        break
    default:
        break
}

and I cut and paste it, I end up with

switch(var)
{
    case value1:
    break
    default:
    break
}

Similar things happen with if/else indenting.

 

I understand that the formatting that I prefer might not be preferred by others... but the issue I am struggling with is how to preserve the format.

 

All ideas are welcome.

 

Thanks

 

Regards

Greg

regards
Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In Visual Studio 2017, pasted code automatically gets re-formatted as you've described. Because I want consistent formatting in my project I generally just go with the imposed format.

 

BTW: Those breaks are placed at the correct indentation level because case labels are just that - labels - they don't create a new block scope.

 

An exception to going with the imposed format is for example when I have spaced out a lookup table so that columns lines up nicely. After pasting simply type one Ctrl-Z and the re-formatting will be undone.

 

Atmel Studio should behave similarly.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you know how to configure AS7.0 C or C++ formatting?

The default is horrible.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

gregd99 wrote:

I understand that the formatting that I prefer might not be preferred by others... but the issue I am struggling with is how to preserve the format.

I know I am late to the party, but I just found this thread as I was looking for a solution for this exact issue.

To preserve formatting when copy/pasting, go to:

VAssistX -> Visual Assist Options... -> Editor

And then remove the checkmark at "Format after paste".