Every pragmatic programmer knows how important it is to master their IDE (integrated development environment). I created a checklist of easy ways to know when you’ve mastered it. Since I primarily use PHP Storm in my workplace I will be providing examples and screenshots from the software.
Move caret to the previous word – ⌥ Left
Move caret to the next word – ⌥ Right
Move caret to end of the line – ^ e
Move caret to beginning of the line – ^ a
Move caret to code block start – ⌘ ⌥ [
Move caret to code block end – ⌘ ⌥ ]
Jump to the beginning of the file – ⌘ Fn Left
Jump to the end of the file – ⌘ Fn Right
Left with selection – ⇧ Left
Right with selection – ⇧ Right
Move caret left and select previous word – ⌥ ⇧ Left
Move caret right and select next word – ⌥ ⇧ Right
Move caret to start of line and select – ⇧ ⌘ Fn Left
Move caret to end of line and select – ⇧ ⌘ Fn Right
Move caret to code block start and select – ⌘ ⌥ ⇧ [
Move caret to code block end and select – ⌘ ⌥ ⇧ ]
Go to function declaration – ⌘ B
If you run ⌘ B
on the function itself you will be able to see all the places where the function is called.
You can set your IDE preferences on a per-language basis in Preferences > Code Style > PHP (for example)
.
Reformat code according to preferences – ⌘ ⌥ L
When the caret is at the beginning, end, or anywhere in between of a variable or function name you can rename it globally. This will look through all the project files for any reference to it. If it determines that they may be duplicates or conflicts, then a dialogue box will pop-up to confirm if you want to make those specific changes.
Globally rename variables and methods – ⇧ F6
You can select the section of code you wish to comment or uncomment and simply type of the following command – ⌘ /
.
This command works both ways and will perform the action depending on if the block or line is commented or not.
When writing methods you can use PHPDoc Blocks in PHP Storm. The doc block will describe what the parameters and return values are. You can also add types to the autogenerated block if you wish to type enforce it.
Above the function you use the command – /** ENTER
When calling this function, the IDE will also look at the parameter names set in the Doc Block to help you identify what parameters need to be there.
By right clicking on the open editor tab you can to split and move the editor window to the right or below.
Go to a specific line number – ⌘ L
This will open a dialogue box that will ask you which line number you wish to go to. If you wish to go to a specific character in the line you can provide two numbers like this 77:21
. The first number is the line, the second is the character in that line.
To search in the file you can use the command – ⌘ F
You can then make selections if you wish to use regex expressions in your search or any other specific parameters.
You can also do the same for replace by using ⌘ R
To perform a global search you use – ⌘ ⇧ F
You can also perform a global search and replace by using – ⌘ ⇧ R
You can make commits and push code either using the purple paper airplane icon in the top right of PHP Storm or using the VCS option in the main menu, then Git, then you have various options as seen below.
Using VCS > Git > Resolve Conflicts it will open a dialogue that looks like the image below that will show you the merge conflicts and allows you to choose what you are going to use.
In the open file, you should see line numbers on the left-hand side. When you right-click on the line numbers you will be able to see the option Annotate. Clicking annotate will show you line by line who made the last edit and when.
You can also choose the option Show Diff to see the variations between all the commits for that file.
On the tests you build you should be able to see a green arrow that when you click on it will run the tests for you.
This requires a lot of configuration so I will leave this for another time. I will make a note that there are different ways to run the debugger for a WordPress site and a Laravel app in PHP Storm.
Stay tuned to learn more.