IdeaVIM is a vim-like input plugin for intellij IDE, good for text editing but not so powerful if you want to use it for other IDE tasks, for example accessing menu actions by defining keyboard shortcuts.
Fortunately, someone in Japan branched the source codes on GitHub, and wrote some tweaks to make it possible to configure all kinds of Intellij menu items to keyboard shortcuts as you wish in a config file.
Tried downloading the modified codes and built it in Intellij; installed the plugin in my Android Studio environment. Working like a charm~
my settings in _ideavim.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.maddyhome.idea.vim.key.KeyParser | |
import com.maddyhome.idea.vim.key.Shortcut | |
import com.maddyhome.idea.vim.command.Command | |
import javax.swing.KeyStroke | |
import java.awt.event.KeyEvent | |
// gc, gf, gs, ga でそれぞれのGotoコマンド実行 | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoClass", Command.Type.OTHER_READONLY, new Shortcut("gc")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoFile", Command.Type.OTHER_READONLY, new Shortcut("gf")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoSymbol", Command.Type.OTHER_READONLY, new Shortcut("gs")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoAction", Command.Type.OTHER_READONLY, new Shortcut("ga")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "ShowUsages", Command.Type.OTHER_READONLY, new Shortcut("su")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "EditorTabPopupMenu", Command.Type.OTHER_READONLY, new Shortcut("gt")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "Run", Command.Type.OTHER_READONLY, new Shortcut("gr")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "Debug", Command.Type.OTHER_READONLY, new Shortcut("gd")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "NextTab", Command.Type.OTHER_READONLY, new Shortcut("bn")) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "PreviousTab", Command.Type.OTHER_READONLY, new Shortcut("bp")) | |
// Ctrl+] で定義に移動。Ctrl+T で戻る | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoDeclaration", Command.Type.OTHER_READONLY, Command.FLAG_MOT_EXCLUSIVE, | |
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, KeyEvent.CTRL_MASK))) | |
parser.registerAction(KeyParser.MAPPING_NORMAL, "Back", Command.Type.OTHER_READONLY, Command.FLAG_MOT_EXCLUSIVE, | |
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK))) |
REF:
http://d.hatena.ne.jp/masanobuimai/20120720/1342764219
http://d.hatena.ne.jp/masanobuimai/20080323#1206277040
沒有留言:
張貼留言