.. _Indentation:

Indentation
===========

-  **Tabs and Spaces** - Lines are indented using tabs or spaces depending on the preferences configured in :menuselection:`Window --> Preferences --> General --> Editors --> Text Editors`: 
    -  If the **Insert spaces for tabs** (org.eclipse.ui.editors/spacesForTabs) option is enabled, indentation will use space characters, otherwise tabs will be used. 
    -  The **Displayed tab width** (org.eclipse.ui.editors/tabWidth) option controls the size of a tab in spaces.
  
- **Auto-detect indentation** - Controls whether DVT will automatically detect the indentation style of the file opened in the editor. It can be configured from :menuselection:`Window --> Preferences --> DVT --> Editors`.

.. note::
    When the **Auto-detect indentation** (ro.amiq.dvt/format.indent.auto_detect) preference is enabled, the detected values will be displayed in the Inspect View and will have a higher priority over the **Insert spaces for tabs** and **Displayed tab width** settings when the formatter is invoked. You can also trigger a new detection from the Inspect View.

.. figure:: ../../images/vhdl_eclipse_file_indent_inspect_view.png
	:align: center

-  **then** (ro.amiq.vhdldt/format.indent.begin) - This option affects the *then* keyword placement:
    -  **Leave as is** (1)
    -  **On a new line** (2) - *then* is moved on a new line
    -  **On the same line** (3) - *then* is moved on the same line with its construct

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Initial code
     - Leave as is (1)
     - On a new line (2)
     - On the same line (3)
   * - .. figure:: ../../images/common/then-same-line.png
     - .. figure:: ../../images/common/then-same-line.png
     - .. figure:: ../../images/common/then-new-line.png
     - .. figure:: ../../images/common/then-same-line.png

-  **Parameters** (ro.amiq.vhdldt/format.indent.params) - This option affects *port*, *generic*, *map*, *function* and *procedure* elements:
    - **Leave as is** (1)
    - **One per line (open parenthesis on the same line)** (2) - Each parameter/argument is placed on its own line and the open parentheses is placed on the same line with the parameter/argument receiver
    - **One per line (open parenthesis on the next line)** (3) - Each parameter/argument is placed on its own line and the open parentheses is placed on the next line after the parameter/argument receiver
    - **More per line if less than** (ro.amiq.vhdldt/format.indent.more_per_line_if_less_than_enable) - It controls whether to place parameters on the same line when their number does not exceed a specified value. This option is available only when the *Parameters* preference is set to *One per line (open parenthesis on the same line)* or *One per line (open parenthesis on the next line)*.
    - **More per line** (4) - More parameters are placed on the same line

.. note:: 
  
  When more parameters get to be placed on a single line and line wrapping is enabled, the parameters may be moved to separate lines as needed to fit within the specified line width.

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Initial code & Leave as is (1)
     - More per line (4)
   * - .. figure:: ../../images/common/parameters-before.png
     - .. figure:: ../../images/common/parameters-more-per-line-vhdl.png



.. list-table::
   :header-rows: 1
   :widths: auto

   * - Initial code
     - One per line (open parenthesis on the next line) (3)
     - One per line (open parenthesis on the next line) (3) and More per line if less than set to "5"
     - One per line (open parenthesis on the next line) (3) and More per line if less than set to "1"
   * - .. figure:: ../../images/common/parameters-before.png
     - .. figure:: ../../images/common/parameters-one-per-line-open-parenthesis-on-the-next-line-vhdl.png
     - .. figure:: ../../images/common/parameters-open-paren-next-line-more-per-line-if-less-than-within-limit-vhdl.png
     - .. figure:: ../../images/common/parameters-one-per-line-open-parenthesis-on-the-next-line-vhdl.png


-  **Don't indent single line comments at first column** (ro.amiq.vhdldt/format.indent.preserve_sl_comment_column_zero) - This option affects single line comments that start at column zero. It is useful to disable the indentation for whole regions of code that are *block commented*, for example by using *Ctrl + /*. When enabled, single line comments that start at column zero are not indented.

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Before
     - After
   * - .. figure:: ../../images/common/before-and-after-do-not-indent-single-line-comments-vhdl.png
     - .. figure:: ../../images/common/before-and-after-do-not-indent-single-line-comments-vhdl.png


-  **Indent multi-line comments** (ro.amiq.vhdldt/format.indent.multiline_comments) - This option affects multi-line comments (*\/\* ... \*\/*). When enabled, multi-line comments are indented.

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Before
     - After
   * - .. figure:: ../../images/common/before-indent-multiline-comments-vhdl.png
     - .. figure:: ../../images/common/after-indent-multiline-comments-vhdl.png


-  **Ignore lines starting with** (ro.amiq.vhdldt/format.indent.ignore_lines) - Space separated list of line prefixes. A line starting with one of the prefixes is completely ignored, that is it is not indented, nor it contributes to indentation.

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Before
     - After
   * - .. figure:: ../../images/common/before-ignore-lines-starting-with-vhdl.png
     - .. figure:: ../../images/common/after-ignore-lines-starting-with-vhdl.png

-  **Don't increase the indent level on** (ro.amiq.vhdldt/format.indent.no_indent_keywords) - By default all *scope* language constructs increase indentation. This option allows you to control which language constructs should increase indentation.

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Before
     - After
   * - .. figure:: ../../images/common/before-no-indent-keywords-vhdl.png
     - .. figure:: ../../images/common/after-no-indent-keywords-vhdl.png


