Connor Smyth

a screenshot of a computer screen

Master Your IDE

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 and make selections by character, word, line, and paragraph

Moving

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

Selecting

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

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.

a screenshot of a cell phone screen with text

Reformat code according to your IDE preferences

You can set your IDE preferences on a per-language basis in Preferences > Code Style > PHP (for example).

Reformat code according to preferences – ⌘ ⌥ L

Globally rename variables and methods

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

Comment and uncomment blocks of code

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.

PHPDoc Blocks

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.

a screenshot of a cell phone

Split the editor window into multiple panels and navigate between them

By right clicking on the open editor tab you can to split and move the editor window to the right or below.

a screenshot of a computer

Go to a specific line number

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.

Search and/or replace strings and regex patterns

In file

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

a close up of a sign

Globally

To perform a global search you use – ⌘ ⇧ F

You can also perform a global search and replace by using – ⌘ ⇧ R

Use your version control system

Commit

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.

a screenshot of a computer screen

Merge conflicts

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.

color coding in the conflict resolution tool

Git blame

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.

a screenshot of text

You can also choose the option Show Diff to see the variations between all the commits for that file.

Run the project’s tests

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.

Run the debugger

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.