- In the editor, select the code block to be extracted and choose on the main menu or on the context menu of the selection.
- In the Extract Include File dialog box that opens,
specify the name of the target include file
in the Name for extracted include file text box.
Type the file name without an extension.
- In the Extract to directory text box, specify the directory to store the include file in. Leave the predefined directory, or redefine it manually, or click the Browse button and choose the desired folder in the Select Target Directory dialog box that opens.
- Click OK, when ready. IntelliJ IDEA extracts the selected source code into the specified file in the target
directory and generates the corresponding reference in the source file.
If there are any duplicates for the selected fragment, IntelliJ IDEA will suggest you to change them for the corresponding reference as well.