Using Vim Editor Emulation in PyCharm (IdeaVim)
The IdeaVim plugin emulates Vim in PyCharm, including normal, insert, and visual modes, Command-line and Ex modes, Vim regexp and configuration, and other features.
Install the IdeaVim plugin
After you restart the PyCharm, Vim emulation is enabled and the editor starts operating in the Vim mode. To disable it, deselectin the main menu.
Both Vim and PyCharm are keyboard-centric. Your keymap in PyCharm may conflict with Vim's key combinations. To resolve this, select the shortcuts you prefer for different actions.
Find the shortcut and corresponding IDE action, and select how you want to handle it when you are using Vim emulation:
Undefined: show a popup notification that suggests to either redefine the IDE shortcut or configure the handler in Vim emulation settings.
IDE: perform the IDE action associated with this shortcut.
Vim: handle it as a Vim shortcut.
With Vim emulation enabled, the cursor is a block when you are in the Normal mode:
To change to the Insert mode, press
i, and the cursor will become a line:
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 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:
If you already have a vimrc file with your configuration, you can do one of the following:
Include the configuration from vimrc with the
sourcecommand 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 PyCharm 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 PyCharm compared to actual Vim configuration:ln -s "$HOME/.vimrc" "$HOME/.ideavimrc"