Refactoring in the DVT Eclipse IDE - How to Move a Code Fragment to a New File
Overview
This video explains how to quickly create a new file from any piece of code. The initial selection gets replaced with an `include of the new file.
This helps you quickly break down large files into smaller ones and reuse code by means of the `include pre-processor directive.
Explore the design and verification tools: https://www.dvteclipse.com
Or request a license: https://www.dvteclipse.com/request-license
Details
Introduction
In DVT, you can easily move a code fragment to a new file. It can help you quickly break down large files and reuse code by means of the include
preprocessor directive.
Steps to Move a Code Fragment to a New File
Select a block of code and press CTRL+1
, then choose Move Selection to New File from the list of proposals. The New File for Selection wizard pops up. Fill in the name and location of the newly created file and press Finish when done.
Navigating Back to the Original File
Right-click and select Show Including File to quickly go back to where you started. Note how the initial selection has been replaced with an include
of the newly created file.
Alternative Method via Context Menu
This refactoring operation can also be triggered from the editor's context menu: Refactor > Move Selection to New File.