Want to run custom action on pre-commit hook

I want to format my code automatic on commit in Visual Studio by Ctrl+K+D function.

Please let me know anyone idea of custom action.