/** @return true if keymap was switched successfully, false otherwise */ public static boolean switchKeymapBindings(final boolean enableVimKeymap) { LOG.debug("Enabling keymap"); // In case if Vim keymap is already in use or we don't need it, we have nothing to do if (isVimKeymapUsed() == enableVimKeymap) { return false; } final KeymapManagerImpl manager = (KeymapManagerImpl) KeymapManager.getInstance(); // Get keymap to enable final String keymapName2Enable = enableVimKeymap ? VIM_KEYMAP_NAME : VimPlugin.getInstance().getPreviousKeyMap(); if (keymapName2Enable.isEmpty()) { return false; } if (keymapName2Enable.equals(manager.getActiveKeymap().getName())) { return false; } LOG.debug("Enabling keymap:" + keymapName2Enable); final Keymap keymap = manager.getKeymap(keymapName2Enable); if (keymap == null) { reportError("Failed to enable keymap: " + keymapName2Enable); return false; } // Save previous keymap to enable after VIM emulation is turned off if (enableVimKeymap) { VimPlugin.getInstance().setPreviousKeyMap(manager.getActiveKeymap().getName()); } manager.setActiveKeymap(keymap); final String keyMapPresentableName = keymap.getPresentableName(); Notifications.Bus.notify( new Notification( VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE, keyMapPresentableName + " keymap was successfully enabled", NotificationType.INFORMATION)); LOG.debug(keyMapPresentableName + " keymap was successfully enabled"); return true; }