PyCharm allows copying and moving code fragments within the active editor tab,
by means of drag-and-drop.
- Make sure that using drag-and-drop is enabled in the Editor page of the IDE Settings.
Select the desired fragment in the editor.
- Move or copy selection:
- Move: Drag the selected fragment to the target location.
- Copy: Keeping the Ctrl key pressed, drag selection to the target location.