Skip to content

Instantly share code, notes, and snippets.

@danielTobon43
Last active September 7, 2023 06:23
Show Gist options
  • Save danielTobon43/51764026f95240bbd03991089f0380a8 to your computer and use it in GitHub Desktop.
Save danielTobon43/51764026f95240bbd03991089f0380a8 to your computer and use it in GitHub Desktop.
Tutorial/Setting up clang-format on Windows 10 for Sublime Text 3

Clang-format for Sublime Text 3 Win10

This tutorial takes you through the steps of setting up clang-formater in your own sublime text 3 software on Windows 10.

Getting Started

These instructions will get you a full clang format to automatically format C/C++/Objective-C code, so that developers don't need to worry about style issues during code reviews. It is highly recommended to format your changed C++ code before opening pull requests, which will save you and the reviewers' time.copy of the project up and running on your local machine for development and testing purposes. This tutorial will take you trough the full installation on a Windows 10.

Prerequisites

What things you need to install.

  • Sublime Text 3: Sublime
  • Clang-format windows 10: LLVM

Setting up clang-format

  • Go to Preferences->Package Control: Install Package
  • Install Clang Format
  • Go to Preferences->Package Settings->Clang Format->Setting-User, set as following:
{
    "binary": "C:/Program Files/LLVM/bin/clang-format.exe",
    "format_on_save": true,
    "style": "Custom",
}
  • Go to Preferences->Package Settings->Clang Format->Custom Style-User, add:
{
    "Language": "Cpp",
    "TabWidth": 4,
    "AlignTrailingComments": "true",
    "UseTab": "Never",
}
  • Save and restart sublime text
  • Go to any script page, save it and see the difference

Reference

Unify code style using clang-format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment