Move to the End and Beginning of a Word in PHPStorm

Another Macintosh keyboard shortcut that will be second nature to most Mac users is using ⌥← to move to the beginning of a word and ⌥→ to move to the end of a word. This moves the cursor to the left of the first character or the right of the last character. Try it in Mail. In TextEdit. In another editor you have installed like Sublime Text. It works the same across any Mac application I can think of except for PHPStorm. It feels so… wrong.

There is no existing Keymap setting in PHPStorm to move to the beginning and end of a word. Instead, there are command for moving to the next and previous words:

Move to Next Word

To fix this abomination, and affront to Clarus the Dogcow, you will need to install a PHPStorm plug-in called “Missing in Actions.” “Missing in Actions” actually will add quite a bit of functionality but, really, the thing that I was really looking for was the proper handling for ⌥← and ⌥→. Read more about Missing in Actions at the plug-in’s Github repository.

Go to PHPStorm > Preferences > Plugins. From there, choose “Browse Repositories.” Search for “Missing in Actions” and click the Install button. The plug-in will download and then you will be prompted to restart PHPStorm for the changes to take effect.

After restart is complete (you may have time to refresh your coffee), you will see new options available in the Keymap settings of PHPStorm:

  • Move Caret to Next End of Word
  • Move Caret to Previous Start of Word

Set these to ⌥→ and ⌥← and all will be well again.

Move Cursor to the Top of the Page in PHPStorm

I have started using JetBrain’s PHPStorm editor at work on a Macintosh and one of the things that has irked me is that some of the standard Macintosh keyboard shortcuts don’t work out of the box. For example, if you’re a seasoned Macintosh user, you are most likely used to using ⌘↑ to go to the top of the document. By default, in PHPStorm, this brings up the breadcrumb navigation. To get the default Macintosh behavior, you’ll want to edit the Keymap Preferences.

Go to PHPStorm > Preferences > Keymap to bring up the Preferences dialog. On the right-hand side of the dialog, you’ll be able to search for the command that you want to set the keyboard shortcut for. It wasn’t obvious to me what the command was for scrolling and moving the cursor to the top in PHPStorm, but I finally found that it is “Move Caret to Page Top.”

Move Caret to Top

Double-click this entry and set it to ⌘↑. Since PHPStorm assigns this by default to the “Show Breadcrumbs” command, you will be given an option to remove this existing mapping.

In addition to setting this keyboard shortcut, you can also set “Move Caret to Page Top with Selection” to Shift-⌘↑ and the corresponding commands for moving the caret to the bottom of the page. In my mind, this makes PHPStorm act much more like you’d expect an editor on the Mac to work.