/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

/*!
    \previouspage creator-completing-code.html
    \page creator-indenting-code.html
    \nextpage qt-quick-toolbars.html

    \title Indenting Text or Code

    When you type text or code, it is indented automatically according to the
    selected text editor or code style options. Select a block to indent it when
    you press \key Tab. Press \key {Shift+Tab} to decrease the indentation. You
    can disable automatic indentation.

    You can specify indentation for:

    \list
        \if defined(qtcreator)
        \li C++ files
        \endif
        \li QML files
        \if defined(qtcreator)
        \li Nim files
        \endif
        \li Other text files
    \endlist

    You can also specify indentation separately for each project. You can
    specify several sets of code style settings and easily switch between them.
    In addition, you can import and export code style settings.

    \if defined(qtcreator)
    \section1 Indenting C++ Files

    To specify indentation settings for the C++ editor:

    \list 1
        \li Select \uicontrol Tools > \uicontrol Options > \uicontrol {C++}.
        \li In the \uicontrol {Current settings} field, select the settings to
            modify and click \uicontrol Copy.
            \image qtcreator-options-code-style-cpp.png "C++ Code Style options"
        \li Give a name to the settings and click \uicontrol OK.
        \li Click \uicontrol Edit to specify code style settings for the project.
            \image qtcreator-code-style-settings-edit-cpp.png "Edit Code Style Settings dialog"
    \endlist

    You can specify how to:

    \list
        \li Interpret the \key Tab and \key Backspace key presses.
        \li Indent the contents of classes, functions, blocks, and namespaces.
        \li Indent braces in classes, namespaces, enums, functions, and blocks.
        \li Control switch statements and their contents.
        \li Align continuation lines.
        \li Bind pointers (*) and references (&) in types and declarations to
            identifiers, type names, or left or right \c const or \c volatile
            keywords.
        \li Name getter functions.
    \endlist

    You can use the live preview to see how the options change the indentation.

    To specify different settings for a particular project, select
    \uicontrol Projects > \uicontrol {Code Style Settings}.

    \include creator-clangformat.qdocinc clang format
    \endif

    \section1 Indenting QML Files

    To specify settings for the Qt Quick editor:

    \list 1
        \li Select \uicontrol Tools > \uicontrol Options >
            \uicontrol {Qt Quick}.
        \li In the \uicontrol {Current settings} field, select the settings to
            modify and click \uicontrol Copy.
            \image qtcreator-options-code-style-qml.png "QML Code Style options"
        \li Give a name to the settings and click \uicontrol OK.
        \li Click \uicontrol Edit to specify code style settings for the project.
            \image qtcreator-code-style-settings-edit-qtquick.png "Edit Code Style Settings dialog"
    \endlist

    You can specify how to interpret the \key Tab key presses and how to align
    continuation lines.

    To specify different settings for a particular project, select
    \uicontrol Projects > \uicontrol {Code Style Settings}.

    \if defined(qtcreator)
    \section1 Indenting Nim Files

    To specify settings for the Nim editor (experimental):

    \list 1
        \li Select \uicontrol Tools > \uicontrol Options > \uicontrol Nim.
        \li In the \uicontrol {Current settings} field, select the settings to
            modify and click \uicontrol Copy.
            \image qtcreator-options-code-style-nim.png "Nim Code Style options"
        \li Give a name to the settings and click \uicontrol OK.
        \li Click \uicontrol Edit to specify code style settings for the project.
            \image qtcreator-code-style-settings-edit-nim.png "Edit Code Style Settings dialog"
    \endlist

    You can specify how to interpret the \key Tab key presses and how to align
    continuation lines.

    To specify different settings for a particular project, select
    \uicontrol Projects > \uicontrol {Code Style}.
    \endif

    \section1 Indenting Other Text Files

    To specify indentation settings for text files that do not contain C++ or
    QML code (such as Python code files), select \uicontrol Tools >
    \uicontrol Options > \uicontrol {Text Editor} > \uicontrol Behavior.

    \image qtcreator-indentation.png "Text Editor Behavior options"

    To specify different settings for a particular project, select
    \uicontrol Projects > \uicontrol Editor.

    You can specify how to interpret the \key Tab and \key Backspace key
    presses and how to align continuation lines.

    \section1 Specifying Tab Settings

    You can specify tab settings at the following levels:

    \list
        \if defined(qtcreator)
        \li For all C++ files
        \endif
        \li For all QML files
        \li For all other text files
        \if defined(qtcreator)
        \li For C++ files in a project
        \endif
        \li For QML files in a project
        \li For other text files in a project
    \endlist

    \section2 Specifying Tabs and Indentation

    You can specify tab policy and tab size in the
    \uicontrol {Tabs and Indentation} group. In the \uicontrol {Tab policy}
    field, select whether to use only spaces or only tabs for indentation,
    or to use a mixture of them.

    By default, the tab length in code editor is 8 spaces and the indent size is
    4 spaces. You can specify the tab length and indent size separately for each
    project and for different types of files.

    You can have continuation lines aligned with the previous line. In the
    \uicontrol {Align continuation lines} field, select
    \uicontrol {Not at all} to disable automatic alignment and indent
    continuation lines to the logical depth. To always use spaces for alignment,
    select \uicontrol {With Spaces}. To follow the \uicontrol {Tab policy},
    select \uicontrol {With Regular Indent}.

    \section1 Specifying Typing Options

    When you type text or code, it is indented automatically according to the
    selected text editor or code style options. To specify typing options,
    select \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} >
    \uicontrol Behavior > \uicontrol Typing.

    To disable automatic indentation,  deselect the
    \uicontrol {Enable automatic indentation} check box.

    You can specify how the indentation is decreased when you press
    \uicontrol Backspace in the \uicontrol {Backspace indentation} field. To go
    back one space at a time, select \uicontrol None. To decrease indentation
    in leading white space by one level, select
    \uicontrol {Follows Previous Indents}. To move back one tab length if the
    character to the left of the cursor is a space, select
    \uicontrol Unindents.

    You can specify whether the \key Tab key automatically indents text when you
    press it. To automatically indent text, select \uicontrol Always in the
    \uicontrol {Tab key performs auto-indent} field. To only indent text when
    the cursor is located within leading white space, select \uicontrol {In
    Leading White Space}.

    \if defined(qtcreator)
    \section1 Specifying Settings for Content

    You can indent public, protected, and private statements and declarations
    related to them within classes.

    You can also indent statements within functions and blocks and declarations
    within namespaces.

    \image qtcreator-code-style-content.png "Content options"

    \section1 Specifying Settings for Braces

    You can indent class, namespace, enum and function declarations and code
    blocks.

    \image qtcreator-code-style-braces.png "Braces options"

    \section1 Specifying Settings for Switch Statements

    You can indent case or default statements, or statements or blocks related
    to them within switch statements.

    \image qtcreator-code-style-switch.png "Switch options"

    \section1 Specifying Alignment

    To align continuation lines to tokens after assignments, such as \c = or
    \c +=, select the \uicontrol {Align after assignments} check box. You can
    specify additional settings for aligning continuation lines in the
    \uicontrol General tab.

    You can also add spaces to conditional statements, so that they are not
    aligned with the following line. Usually, this only affects \c if
    statements.

    \image qtcreator-code-style-alignment.png "Alignment options"

    \section1 Binding Pointers and References

    To bind pointers (\c *) and references (\c &) in types and declarations to
    identifiers, type names, or left or right \c const or \c volatile keywords,
    select the check boxes in the \uicontrol {Pointers and References} tab.

    The \c * and \c & characters are automatically bound to identifiers of
    pointers to functions and pointers to arrays.

    \image qtcreator-pointers-references.png "Pointers and References options"

    \section1 Naming Getters

    To prefer getter names without the string \e get, select the
    \uicontrol {Prefer getter names without "get"} check box in the
    \uicontrol {Getter and Setter} tab.

    \image qtcreator-code-style-getter-setter.png
    \endif
*/
