PhpStorm 2019.2 Help

Using PhpStorm as the Vim Editor

The IdeaVim plugin emulates Vim in PhpStorm, including normal, insert, and visual modes, Command-line and Ex modes, Vim regexp and configuration, and other features.

Install the IdeaVim plugin

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Plugins.

  2. Find the IdeaVim plugin in the Marketplace and click Install.

  3. Restart PhpStorm.

After you restart PhpStorm, Vim emulation is enabled. To disable it, select Tools | Vim Emulator from the main menu.

Configure shortcuts

Both Vim and PhpStorm are keyboard-centric. Your keymap in PhpStorm may conflict with Vim's key combinations. To resolve this, select the shortcuts you prefer for different actions.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Editor | Vim Emulation.

  2. Find the shortcut and corresponding IDE action, and select how you want to handle it when you are using Vim emulation:

    Vim Emulation settings
    • Undefined: show a popup notification that suggests to either redefine the IDE shortcut or configure the handler in Vim emulation settings.

      Shortcut notification
    • IDE: perform the IDE action associated with this shortcut.

    • Vim: handle it as a Vim shortcut.

Editing modes

With Vim emulation enabled, the cursor is a block when you are in the Normal mode:

Vim emulation Normal mode

To change to the Insert mode, press i, and the cursor will become a line:

Vim emulation Insert mode

In this mode you can type new code or change existing code. You can also enter other Vim modes: for example, press r for the Replace mode.

To return to the Normal mode, press Escape.

Vim configuration

Vim is configured using a vimrc file. Similarly, the VimIdea plugin uses an ideavimrc file with the same syntax. Create the configuration file in one of the following locations depending on the operating system:

%HOMEPATH%\_ideavimrc
~/.ideavimrc
~/.ideavimrc

If you already have a vimrc file with your configuration, you can do one of the following:

  • Include the configuration from vimrc with the source command in your ideavimrc file:

    source ~/.vimrc

    This way you can also include other commands in your ideavimrc file, which will be applied only to your Vim emulation in PhpStorm and will not affect actual Vim configuration.

  • If you don't want to use your Vim configuration, you can rename .vimrc to .ideavimrc.

  • Create ideavimrc as a symlink to vimrc if you don't want to modify your Vim emulation in PhpStorm compared to actual Vim configuration:

    ln -s "$HOME/.vimrc" "$HOME/.ideavimrc"
Last modified: 22 October 2019