Closed blukat29 closed 10 years ago
wait, partial, repeat, motion, operator, operatorMotion, action, search, ex
mode
and state
, given a keystroke, find out which type of command it is.For step 2, refer to...
vim.js
Key handling routine - the outermost callback invoked by CodeMirror.
Below is pseudocode, with some logics omitted.
function handleKey(cm, key) {
var vim = maybeInitVimState(cm); // initialize only at the first run.
// Exit visual state on Esc.
if (key == '<Esc>') {
clearInputState(cm);
if (vim.isVisualMode)
vim.exitVisualMode();
}
// '0' is special case since it is both motion and repeat digit.
if (key != '0' || (key == '0' && vim.inputState.getRepeat() == 0)) {
command = commandDispatcher.matchCommand(key, defaultKeymap, vim);
}
// Not a command. (can be numbers)
if (!command) {
if (isNumber(key))
vim.inputState.pushRepeatDigit(key);
else
(unknown command)
return;
}
// Process key to key mapping.
if (command.type == 'keyToKey') {
this.handleKey(cm, command.toKeys[]);
}
// Process ordinary commands
commandDispatcher.processCommand(cm, vim, command);
}
// Separate function for ex commands.
function handleEx(cm, input) {
exCommandDispatcher.processCommand(cm, input);
}
Close and continue on new issue.
Vim Grammar http://takac.github.io/2013/01/30/vim-grammar/ http://takac.github.io/assets/grammar-slide.html http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/ http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/