Skip to content

Instantly share code, notes, and snippets.

@Uflex
Last active November 3, 2019 16:19

Revisions

  1. Uflex revised this gist Apr 30, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    Clang-format in QtCreator
    =========================

    **Edit**: QtCreator 3.1 introduced a new plugin called Beautifier that supports clang-format. You still have to install the clang tools separately but you don't have to add them as external tools anymore. The plugin can be configured in the options dialog under the beautifier tab > Clang Format. Add a new style and copy the configuration below without the curly braces.

    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. As of today, you should use it as an external tool, either replacing your selection or the entire file. If you choose to replace the file, you will have to save it before launching the tool and QtCreator will reload the file, making it impossible to undo/redo afterwards. If you choose to replace your selection, you often have to select the whole function, otherwise you will lose the indentation; clang-format doesn't seem to keep the leading spaces. When you run clang-format on your selection, Creator marks the whole selection as changed, even if nothing moved. This is a minor inconvenience and anyway the "Auto-indent Selection" built-in with Creator does the same thing.

    ### Installation
  2. Uflex revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,6 @@ See these links for all possible parameters and enum values (that are not listed
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
    - http://clang.llvm.org/docs/ClangFormat.html

    You can assign a shortcut to that command (I personally use `Ctrl+Shift+I` to keep the built-in formatting tool accessible). Go to `Tools > Options... > Environment > Keyboard` and at the very bottom there is the Tools category.
    You can assign a shortcut to that command (I personally use `Ctrl+Shift+I` on Windows and `⌘⌥I` on Mac to keep the built-in formatting tool accessible). Go to `Tools > Options... > Environment > Keyboard` and at the very bottom there is the Tools category.

    Enjoy! :)
  3. Uflex revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.

    *EDIT*: It seems that there are now official builds for most OSes on the download page: http://llvm.org/releases/download.html
    **EDIT**: It seems that there are now official builds for most OSes on the download page: http://llvm.org/releases/download.html

    ### Configuration

  4. Uflex revised this gist Feb 7, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111
    ### Installation

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.

    *EDIT*: It seems that there are now official builds for most OSes on the download page: http://llvm.org/releases/download.html

    ### Configuration
  5. Uflex revised this gist Feb 7, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111
    ### Installation

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.
    *EDIT*: It seems that there are now official builds for most OSes on the download page: http://llvm.org/releases/download.html

    ### Configuration

  6. Uflex revised this gist Oct 23, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,10 @@ In QtCreator, add an external tool (Tools > Options... > Environment > External
    - Working dir: `%{CurrentProject:Path}` (seems to be optional, works without it)
    - Output: replace selection
    - Error output: show in pane
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool and should be ticked if you want to update the whole file instead of only the selection)
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool)
    - Input: `%{CurrentDocument:Selection}`

    If you want to correct the whole file, leave the input field empty, set the output to "Show in Pane" and add `-i %{CurrentDocument:FilePath}` to the arguments.
    If you want to correct the whole file, leave the input field empty, tick the "Modifies current document", set the output to "Show in Pane" and add `-i %{CurrentDocument:FilePath}` to the arguments.

    See these links for all possible parameters and enum values (that are not listed in the -help option):
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
  7. Uflex revised this gist Oct 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ In QtCreator, add an external tool (Tools > Options... > Environment > External
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool and should be ticked if you want to update the whole file instead of only the selection)
    - Input: `%{CurrentDocument:Selection}`

    If you want to correct the whole file, leave the input field empty and add `-i %{CurrentDocument:FilePath}` to the arguments.
    If you want to correct the whole file, leave the input field empty, set the output to "Show in Pane" and add `-i %{CurrentDocument:FilePath}` to the arguments.

    See these links for all possible parameters and enum values (that are not listed in the -help option):
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
  8. Uflex revised this gist Oct 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, AccessModifierOffset: -4, BreakBeforeBinaryOperators: true, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
    - Working dir: `%{CurrentProject:Path}` (seems to be optional, works without it)
    - Output: replace selection
    - Error output: show in pane
  9. Uflex revised this gist Oct 23, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Clang-format in QtCreator
    =========================

    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. For now, you should use it as an external tool, either replacing your selection (described below) or the entire file.
    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. As of today, you should use it as an external tool, either replacing your selection or the entire file. If you choose to replace the file, you will have to save it before launching the tool and QtCreator will reload the file, making it impossible to undo/redo afterwards. If you choose to replace your selection, you often have to select the whole function, otherwise you will lose the indentation; clang-format doesn't seem to keep the leading spaces. When you run clang-format on your selection, Creator marks the whole selection as changed, even if nothing moved. This is a minor inconvenience and anyway the "Auto-indent Selection" built-in with Creator does the same thing.

    ### Installation

    @@ -16,12 +16,14 @@ In QtCreator, add an external tool (Tools > Options... > Environment > External
    - Output: replace selection
    - Error output: show in pane
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool and should be ticked if you want to update the whole file instead of only the selection)
    - Input: `%{CurrentDocument:Selection}`
    - Input: `%{CurrentDocument:Selection}`

    See these for all possible parameters and enum values (that are not listed in the -help option):
    If you want to correct the whole file, leave the input field empty and add `-i %{CurrentDocument:FilePath}` to the arguments.

    See these links for all possible parameters and enum values (that are not listed in the -help option):
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
    - http://clang.llvm.org/docs/ClangFormat.html

    You can assign a shortcut to that command (I personally use `ctrl+shift+I` to keep the built-in formatting tool accessible). Go to `Tools > Options... > Environment > Keyboard` and at the very bottom there is the Tools category.
    You can assign a shortcut to that command (I personally use `Ctrl+Shift+I` to keep the built-in formatting tool accessible). Go to `Tools > Options... > Environment > Keyboard` and at the very bottom there is the Tools category.

    Enjoy! :)
  10. Uflex revised this gist Oct 21, 2013. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,11 @@ Clang-format in QtCreator

    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. For now, you should use it as an external tool, either replacing your selection (described below) or the entire file.

    Installation
    ------------
    ### Installation

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.

    Configuration
    -------------
    ### Configuration

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

  11. Uflex revised this gist Oct 21, 2013. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,16 @@
    Clang-format in QtCreator
    =========================

    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. For now, you should use it as an external tool, either replacing your selection (described below) or the entire file.

    Installation
    ------------

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.

    Configuration
    -------------

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
  12. Uflex revised this gist Oct 21, 2013. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,16 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i
    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
    - Working dir: `%{CurrentProject:Path}`
    - Working dir: `%{CurrentProject:Path}` (seems to be optional, works without it)
    - Output: replace selection
    - Error output: show in pane
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool and should be ticked if you want to update the whole file instead of only the selection)
    - Input: `%{CurrentDocument:Selection}`

    See these for all possible parameters and enum values (that are not listed in the -help option):
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
    - http://clang.llvm.org/docs/ClangFormat.html
    - http://clang.llvm.org/docs/ClangFormat.html

    You can assign a shortcut to that command (I personally use `ctrl+shift+I` to keep the built-in formatting tool accessible). Go to `Tools > Options... > Environment > Keyboard` and at the very bottom there is the Tools category.

    Enjoy! :)
  13. Uflex revised this gist Oct 21, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,12 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i
    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
    - Working dir: %{CurrentProject:Path}
    - Working dir: `%{CurrentProject:Path}`
    - Output: replace selection
    - Error output: show in pane
    - Don't tick the "Modifies current document"
    - Input: %{CurrentDocument:Selection}
    - *Don't tick* the "Modifies current document" (this will ask you to save the document before running the tool and should be ticked if you want to update the whole file instead of only the selection)
    - Input: `%{CurrentDocument:Selection}`

    See these for all possible parameters:
    See these for all possible parameters and enum values (that are not listed in the -help option):
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
    - http://clang.llvm.org/docs/ClangFormat.html
  14. Uflex revised this gist Oct 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: `-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"`
    - Arguments: <blockquote>-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"</blockquote>
    - Working dir: %{CurrentProject:Path}
    - Output: replace selection
    - Error output: show in pane
  15. Uflex revised this gist Oct 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    - Arguments: -style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"
    - Arguments: `-style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"`
    - Working dir: %{CurrentProject:Path}
    - Output: replace selection
    - Error output: show in pane
  16. Uflex revised this gist Oct 21, 2013. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,12 @@ For Windows, download LLVM from http://llvm.org/builds/. You don't need to add i

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    Arguments: -style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"
    Working dir: %{CurrentProject:Path}
    Output: replace selection
    Error output: show in pane
    Don't tick the "Modifies current document"
    Input: %{CurrentDocument:Selection}
    - Arguments: -style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"
    - Working dir: %{CurrentProject:Path}
    - Output: replace selection
    - Error output: show in pane
    - Don't tick the "Modifies current document"
    - Input: %{CurrentDocument:Selection}

    See these for all possible parameters:
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
  17. Uflex created this gist Oct 21, 2013.
    16 changes: 16 additions & 0 deletions clang-format_config.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    QtCreator doesn't allow using clang-format by default. Watch [QTCREATORBUG-10111](https://bugreports.qt-project.org/browse/QTCREATORBUG-10111) for a better integration. For now, you should use it as an external tool, either replacing your selection (described below) or the entire file.

    For Windows, download LLVM from http://llvm.org/builds/. You don't need to add it to the PATH, you can use it with the absolute path.

    In QtCreator, add an external tool (Tools > Options... > Environment > External Tools > Add > Add Tool).

    Arguments: -style="{BasedOnStyle: llvm, ColumnLimit: 80, Standard: Cpp11, IndentWidth: 4, BreakBeforeBraces: Linux}"
    Working dir: %{CurrentProject:Path}
    Output: replace selection
    Error output: show in pane
    Don't tick the "Modifies current document"
    Input: %{CurrentDocument:Selection}

    See these for all possible parameters:
    - http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html
    - http://clang.llvm.org/docs/ClangFormat.html