microsoft / microsoft/vscode-cpptools
Request: Smart indentation on preprocessor directives
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Hi,
Sometimes I would like to write some code like this:
#ifdef _SOME_COND_
xxx;
yyyy;
zzzzz;
#endif
However currently in VS Code the "closing" directives are not automatically outdented, so I end up something like this:
#ifdef _SOME_COND_
xxx;
yyyy;
zzzzz;
#endif
I hope the directives like #else, #elif, #endif can be automatically aligned to the nearest #if, #ifdef, or other corresponding "opening" directives.
Please consider this. Thank you.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by locating the VS Code C/C++ extension's indentation handling for preprocessor directives, then trace how #if, #ifdef, #else, #elif, and #endif are recognized. Done means closing and alternate directives align with their corresponding opening directive in the demonstrated C example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100