// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-indenting-code.html
    \if defined(qtdesignstudio)
    \previouspage qtquick-text-editor.html
    \else
    \previouspage creator-how-tos.html
    \endif

    \ingroup creator-how-to-edit
    \ingroup studio-how-to-code

    \title Indent text or code

    When you type text or code, it is indented automatically according to the
    selected text editor or code style preferences. Select a block to indent it when
    you select \key Tab. Select \key {Shift+Tab} to decrease the indentation.

    \section1 Don't detect indentation settings

    To turn off the automatic detection of indentation settings, go to
    \preferences > \uicontrol {Text Editor} > \uicontrol Behavior
    and clear \uicontrol {Auto detect}.

    \image qtcreator-preferences-texteditor-behavior-indentation.webp {Text Editor Behavior indentation preferences}

    \section1 Fix indentation in an open file

    To fix the indentation in the file currently open in the editor:

    \list
        \li On the editor toolbar, select \uicontrol {Spaces}, and then select
            \uicontrol {Auto-indent Selection} to automatically indent the
            selected text using the current settings.
        \li Go to \uicontrol Edit > \uicontrol Advanced, and select an
            indentation option or use \l{Keyboard Shortcuts}{keyboard shortcuts}.
    \endlist

    \section2 Indentation options

    \list
        \li To automatically indent the highlighted text, select
            \uicontrol {Auto-indent Selection} or select \key {Ctrl+I}.
        \li To automatically format the highlighted text, select
            \uicontrol {Auto-format Selection} or select \key {Ctrl+;}.
        \li To adjust the wrapping of the selected paragraph, select
            \uicontrol {Rewrap Paragraph} or select \key {Ctrl+E}
            followed by \key R.
        \li To toggle text wrapping, select \uicontrol {Enable Text Wrapping}
             or select \key {Ctrl+E} followed by \key {Ctrl+W}.
        \li To visualize whitespace in the editor, select
            \uicontrol {Visualize Whitespace} or select \key {Ctrl+E}
            followed by \key {Ctrl+V}.
        \li To clear all whitespace characters from the currently open file,
            select \uicontrol {Clean Whitespace}.
    \endlist

    \section1 Automatically fix indentation upon file save

    To automatically fix indentation according to the indentation settings
    when you save the file, go to \preferences > \uicontrol {Text Editor} >
    \uicontrol Behavior > \uicontrol {Clean whitespace} and select
    \uicontrol {Clean indentation}. Select
    \uicontrol {Skip clean whitespace for file types} to
    exclude the specified file types.

    \image qtcreator-preferences-texteditor-behavior.webp {Text Editor Behavior preferences}

    \section1 Show whitespace in editor

    To visualize whitespace in the editor, go to \preferences >
    \uicontrol {Text Editor} > \uicontrol Display >
    \uicontrol {Visualize whitespace}.

    To visualize indentation, select \uicontrol {Visualize Indent}. To adjust the
    color of the visualization, change the value of the Visual Whitespace setting
    of the editor color scheme in \uicontrol {Font & Colors}.

    \image qtcreator-options-text-editor-display.png {Text Editor Display preferences}

    \section1 Display right margin

    To help you keep line length at a particular number of characters, set the
    number of characters in \uicontrol {Display right margin at column}.
    To use a different color for the margin area, select
    \uicontrol {Tint whole margin area}. Clear it to show
    the margin as a vertical line.

    To use a context-specific margin when available, select
    \uicontrol {Use context-specific margin}.
    \if defined(qtcreator)
    Then, use the \l{ClangFormat Style Options}{ClangFormat} \c ColumnLimit
    option to set the margin, for example.

    \sa {C++ Code Style}
    \endif

    \sa {Behavior}, {Qt Quick Code Style}, {Keyboard Shortcuts}
*/
