Make tab size follow project .clang-format file ? #163485
Replies: 5 comments
-
| If you feel that tabbed indentation in code rendered on GitHub takes up too much, or too little space, you can change this in your settings. Check out our docs for more information. | 
Beta Was this translation helpful? Give feedback.
-
| As of now, GitHub’s web UI does not automatically apply .clang-format settings (like tab size) to code display in the browser. ❌ Current Behavior The web viewer uses default syntax highlighting and tab size (typically 8 spaces) for all files. Even if .clang-format exists in your repo, GitHub does not honor formatting rules like IndentWidth or TabWidth for display purposes. ✅ What You Can Do Pre-format files before committing Submit feedback to GitHub 🧩 Workaround for Repos with Mixed Styles Use GitHub Actions (like cpp-linter) to auto-check .clang-format compliance on PRs. 📝 SummaryAs of now, GitHub’s web UI does not automatically apply .clang-format settings (like tab size) to code display in the browser. ❌ Current Behavior The web viewer uses default syntax highlighting and tab size (typically 8 spaces) for all files. Even if .clang-format exists in your repo, GitHub does not honor formatting rules like IndentWidth or TabWidth for display purposes. ✅ What You Can Do Pre-format files before committing Submit feedback to GitHub 🧩 Workaround for Repos with Mixed Styles Use GitHub Actions (like cpp-linter) to auto-check .clang-format compliance on PRs. | 
Beta Was this translation helpful? Give feedback.
-
| 🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as  2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the  Thank you for helping bring this Discussion to a resolution! 💬 | 
Beta Was this translation helpful? Give feedback.
-
| Hi, At the moment, GitHub’s web UI does not parse or apply .clang-format (or other formatter configuration files) when displaying code in the browser. The .clang-format file is respected by local tools and editors (like VS Code, CLion, or clang-format CLI), but GitHub’s code viewer renders files with its own default tab size and style, not project-specific formatting rules. If you want the web view to match your project’s .clang-format rules, you’ll need to: Run clang-format locally (or set up a pre-commit hook) so code is checked in already formatted. Optionally add a CI workflow to enforce formatting consistency across contributors. There’s an open feature request from developers for GitHub to support repo-specific formatting configs in the UI, but as of now it isn’t available. | 
Beta Was this translation helpful? Give feedback.
-
| 🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as  2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the  Thank you for helping bring this Discussion to a resolution! 💬 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Can GitHub identify the .clang-format file in the repo, follow its tab size settings, and display code in the web accordingly?
Beta Was this translation helpful? Give feedback.
All reactions