I’m encountering an issue where Prettier automatically reformats my C++ macros into a single line, even though I’ve tried using the // prettier-ignore directive. Here’s an example of my code:
`// Expected formatting
#define vo(a)
for (auto x : a)
{
cout << x << " ";
}
cout << endl;`
However, Prettier reformats it into a single line:
#define vo(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
What I’ve Tried:
- Placing // prettier-ignore before the macro definition.
- Checking my Prettier configuration file (.prettierrc) for any settings that might override the ignore directive.
- Using a .prettierignore file to exclude the specific file.
Despite these efforts, Prettier continues to reformat the macro. I want to preserve the multi-line structure for readability and maintainability.
Questions:
- How can I prevent Prettier from reformatting my C++ macros into a single line?
- Is there a configuration or setting in Prettier or my editor that I might miss?
New contributor
Ritul Patel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.