You can easily move a code fragment to a separate new method. This is called **extract method** refactoring. It helps keeping methods shorter and easier to understand.

Select a block of actions and press :kbd:`Ctrl+1`, select **Extract to task** or **Extract to function** from the list of quick assist proposals and press  :kbd:`Enter`.

.. figure:: ../../images/common/sv_quick_assist_extract_to_method_list.png


A new method is created containing the selected code fragment, and the selection is replaced with a method call.

.. figure:: ../../images/common/sv_quick_assist_extract_to_method_after.png

.. note::

	Any local variables declared prior to the code fragment you extracted become arguments of the newly created method. Each argument direction is computed accordingly:

	-  *input* for arguments that are *only read*
	-  *output* for arguments that are *only written*
	-  *inout* for arguments that are both *read and written* in the selected block of actions

.. note::

	By default, if and loop conditions are evaluated to the logic data type, according to the IEEE 1800-2023 Standard for SystemVerilog. You can enforce the data type to bit by going to :menuselection:`Window --> Preferences --> DVT --> SystemVerilog --> Refactoring` and enabling **Enforce condition data type to bit**.
	
	This preference applies only when you select the whole condition.

.. tip::

	You may change the extracted method name in the edit box, right after the extract action is completed.

.. tip::

	You can change the method signature by editing the :ref:`Method Code Templates`

.. tip::

	You can also :kbd:`Right-Click` in the editor and go to **Refactor** > **Extract to Task** or **Extract to Function**.

.. figure:: ../../images/common/sv_quick_assist_extract_to_method_menu.png


