Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving up/down methods in PhpStorm

Tags:

php

phpstorm

I like organising my methods in a class so that protected functions are on the bottom, public on the top. Sometimes, I write a protected method on the bottom of the file and then I realize it's actually a public method.

Is there a keyboard shortcut to move methods up/down without using the standard cut (Ctrl+X) / paste (Ctrl+V) features in PhpStorm?

like image 621
TroodoN-Mike Avatar asked Feb 09 '14 09:02

TroodoN-Mike


1 Answers

Code | Move Statement Up/Down Ctrl + Shift + Up/Down -- no selection required: just place cursor in function declaration line.

Alternatively:
Configure your ordering rules at Settings | Code Style | PHP | Arrangement and then use Code | Rearrange Code (selection is required, AFAIK). If such action is not available then reformat your whole file (Code | Reformat Code...) -- it has an option to rearrange entries.

like image 176
LazyOne Avatar answered Sep 18 '22 05:09

LazyOne