Search code examples
visual-studioversion-controltabs

Visual Studio 2022 convert spaces to tabs on checkout and back to spaces on checkin


I'm working with people who want to make leading spaces mandatory in our DevOps codebase. I use tabs. Is there a way to configure Visual Studio 2022 to automatically convert leading spaces to tabs when I check out a file, and back to spaces when I check it in?

This project will use Git version control, so it looks like the "Team Foundation check-in policy" trick won't work(?).


Solution

  • In the end, I managed to implement a Git pre-commit hook that mangles the files to my coworkers' masochistic standards, and notifies Git of what it just did so the automated changes are actually committed.

    git diff --cached --name-only --diff-filter=AM | "C:\<path>\MyGitPreCommit.exe" && git add -u