Skip to end of metadata
Go to start of metadata

What this tutorial is about

If you are a dedicated Vim fan, and cannot go on coding in a different editor, then this tutorial is for you. It aims to walk you step by step through downloading, installing and using Vim under PyCharm, with the help of IdeaVim plug-in.

What this tutorial is not about

Python programming is out of scope of this tutorial. To learn more about the Python language, please refer to the official website.
We also will not teach you Vim. Refer to the Vim documentation for more information.

Before you start

Make sure that you are working with PyCharm version 2.7 or higher. If you still do not have PyCharm, download it from this page. To install PyCharm, follow the instructions, depending on your platform.

Downloading and installing IdeaVim plug-in

On the toolbar of the PyCharm main window, click to open the Settings dialog. There, under IDE Settings, click the page Plugins.
You see the list of plugins currently installed on you computer. However, the IdeaVim plug-in is not among them. Click the button Browse JetBrains plugins. PyCharm shows the contents of the JetBrains repository, which is not so small... you can type the word "vim" in the search field to narrow down the list:

Install the plugin:

It will become available after PyCharm restart:

What happens to PyCharm after restart?

Both Vim and PyCharm are keyboard-centric. With IdeaVim plugin, it is quite possible that PyCharm's keymap runs into a conflict with the Vim keymap. That's why PyCharm creates its own Vim-oriented keymap, on the base of one of the existing keymaps. This is how it's done.

When PyCharm starts again, you see the dialog box Vim Keymap settings. Here you have to choose one of the existing keymaps, on whose base the new Vim-oriented keymap will be created:

In this case, let's select the default keymap, and click OK. PyCharm configures and enables the new keymap with the name Vim, which is reported in the Event Log:

Let's then have a look at the keymap settings. Again click to open the Settings dialog. There, under IDE Settings, click the page Keymap. Look at the Keymaps drop-down list: it shows the new keymap with the name Vim. It redefines some of the default shortcuts, for example, Ctrl+V for Paste:

However, there is one more important addition to the PyCharm's UI. On the main menu, click Tools, and see the check command Vim Emulator:

When you have just installed the IdeaVim plug-in, this check command is selected, which means that Vim emulator is enabled. You can easily disable it by clearing this check command. PyCharm will immediately enable the base keymap - in our case, this is the Default keymap. If you select this check command again, PyCharm will enable the Vim keymap. Both actions are reported in the balloons:

Editing modes

OK, now that you have Vim enabled, you see that the cursor has changed its shape - now it is a block, which means that you are in Normal mode:

If you want to enter the Insert mode, press i, and the cursor will turn into a line:

In this mode you can type new or change the existing code. Same way, you can enter the various Vim modes: for example, press r for the Replace mode.

By the way, as soon as you enter Vim emulation, it is also reported in the Status bar:

To return to the Normal mode, press Esc

IdeaVim supports many Vim features including shortcuts, motion keys, many types of commands, registers, macros, modes and a lot more.

Your Rating: Results: PatheticBadOKGoodOutstanding! 56 rates
  • No labels