Skip to content

Instantly share code, notes, and snippets.

@masanobuimai
Created September 24, 2012 05:01
Show Gist options
  • Save masanobuimai/3774252 to your computer and use it in GitHub Desktop.
Save masanobuimai/3774252 to your computer and use it in GitHub Desktop.
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
// Input Method制御のおまじない( windows / osx )
System.properties["ideavim.imcontrol"] = "windows"
// gc, gf, gs, ga でそれぞれのGotoコマンド実行
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoClass", Command.OTHER_READONLY, new Shortcut("gc"))
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoFile", Command.OTHER_READONLY, new Shortcut("gf"))
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoSymbol", Command.OTHER_READONLY, new Shortcut("gs"))
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoTest", Command.OTHER_READONLY, new Shortcut("gt"))
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoAction", Command.OTHER_READONLY, new Shortcut("ga"))
// Ctrl+] で定義に移動。Ctrl+T で戻る
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoDeclaration", Command.OTHER_READONLY, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, KeyEvent.CTRL_MASK)))
parser.registerAction(KeyParser.MAPPING_NORMAL, "Back", Command.OTHER_READONLY, Command.FLAG_MOT_EXCLUSIVE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK)))
// J を IntelliJ の join lines にリマップ
parser.registerAction(KeyParser.MAPPING_NORMAL, "EditorJoinLines", Command.OTHER_READONLY, new Shortcut("J"))
// Ctrl-n, Ctrl-p でキーワード補完
parser.registerAction(KeyParser.MAPPING_INSERT, "HippieBackwardCompletion", Command.COMPLETION, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)));
parser.registerAction(KeyParser.MAPPING_INSERT, "HippieCompletion", Command.COMPLETION, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK)));
// Ctrl-j, Ctrl-k でカーソル移動
parser.registerAction(KeyParser.MAPPING_INSERT, "EditorDown", Command.COMPLETION, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_J, KeyEvent.CTRL_MASK)));
parser.registerAction(KeyParser.MAPPING_INSERT, "EditorUp", Command.COMPLETION, Command.FLAG_SAVE_STROKE,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_K, KeyEvent.CTRL_MASK)));
// 矩形選択を Ctrl+SHIFT+q にリマップ
//parser.registerAction(KeyParser.MAPPING_NORMAL | KeyParser.MAPPING_VISUAL, "VimVisualToggleBlockMode", Command.OTHER_READONLY,
// Command.FLAG_MOT_BLOCKWISE, new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK)))
// Ctrl-., Ctrl-, でincrement/decrement (要Shifter)
parser.registerAction(KeyParser.MAPPING_NORMAL, "ShiftUpAction", Command.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, KeyEvent.CTRL_MASK)));
parser.registerAction(KeyParser.MAPPING_NORMAL, "ShiftDownAction", Command.OTHER_READONLY,
new Shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, KeyEvent.CTRL_MASK)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment