public/js/vendor/codemirror3/keymap/vim.js
function buildVimKeyMap() {
      /**
       * Handle the raw key event from CodeMirror. Translate the
       * Shift + key modifier to the resulting letter, while preserving other
       * modifers.
       */
      // TODO: Figure out a way to catch capslock.
      function cmKeyToVimKey(key, modifier) {
        var vimKey = key;
        if (isUpperCase(vimKey)) {
          // Convert to lower case if shift is not the modifier since the key
          // we get from CodeMirror is always upper case.
          if (modifier == 'Shift') {
            modifier = null;
          }
          else {
            vimKey = vimKey.toLowerCase();
          }
        }
        if (modifier) {
          // Vim will parse modifier+key combination as a single key.
          vimKey = modifier.charAt(0) + '-' + vimKey;
        }
        var specialKey = ({Enter:'CR',Backspace:'BS',Delete:'Del'})[vimKey];
        vimKey = specialKey ? specialKey : vimKey;
        vimKey = vimKey.length > 1 ? '<'+ vimKey + '>' : vimKey;
        return vimKey;
      }

      // Closure to bind CodeMirror, key, modifier.
      function keyMapper(vimKey) {
        return function(cm) {
          CodeMirror.Vim.handleKey(cm, vimKey);
        };
      }

      var cmToVimKeymap = {
        'nofallthrough': true,
        'style': 'fat-cursor'
      };
      function bindKeys(keys, modifier) {
        for (var i = 0; i < keys.length; i++) {
          var key = keys[i];
          if (!modifier && inArray(key, specialSymbols)) {
            // Wrap special symbols with '' because that's how CodeMirror binds
            // them.
            key = "'" + key + "'";
          }
          var vimKey = cmKeyToVimKey(keys[i], modifier);
          var cmKey = modifier ? modifier + '-' + key : key;
          cmToVimKeymap[cmKey] = keyMapper(vimKey);
        }
      }
      bindKeys(upperCaseAlphabet);
      bindKeys(upperCaseAlphabet, 'Shift');
      bindKeys(upperCaseAlphabet, 'Ctrl');
      bindKeys(specialSymbols);
      bindKeys(specialSymbols, 'Ctrl');
      bindKeys(numbers);
      bindKeys(numbers, 'Ctrl');
      bindKeys(specialKeys);
      bindKeys(specialKeys, 'Ctrl');
      return cmToVimKeymap;
    }
function buildVimKeyMap() {
      /**
       * Handle the raw key event from CodeMirror. Translate the
       * Shift + key modifier to the resulting letter, while preserving other
       * modifers.
       */
      // TODO: Figure out a way to catch capslock.
      function cmKeyToVimKey(key, modifier) {
        var vimKey = key;
        if (isUpperCase(vimKey)) {
          // Convert to lower case if shift is not the modifier since the key
          // we get from CodeMirror is always upper case.
          if (modifier == 'Shift') {
            modifier = null;
          }
          else {
            vimKey = vimKey.toLowerCase();
          }
        }
        if (modifier) {
          // Vim will parse modifier+key combination as a single key.
          vimKey = modifier.charAt(0) + '-' + vimKey;
        }
        var specialKey = ({Enter:'CR',Backspace:'BS',Delete:'Del'})[vimKey];
        vimKey = specialKey ? specialKey : vimKey;
        vimKey = vimKey.length > 1 ? '<'+ vimKey + '>' : vimKey;
        return vimKey;
      }

      // Closure to bind CodeMirror, key, modifier.
      function keyMapper(vimKey) {
        return function(cm) {
          CodeMirror.Vim.handleKey(cm, vimKey);
        };
      }

      var cmToVimKeymap = {
        'nofallthrough': true,
        'style': 'fat-cursor'
      };
      function bindKeys(keys, modifier) {
        for (var i = 0; i < keys.length; i++) {
          var key = keys[i];
          if (!modifier && inArray(key, specialSymbols)) {
            // Wrap special symbols with '' because that's how CodeMirror binds
            // them.
            key = "'" + key + "'";
          }
          var vimKey = cmKeyToVimKey(keys[i], modifier);
          var cmKey = modifier ? modifier + '-' + key : key;
          cmToVimKeymap[cmKey] = keyMapper(vimKey);
        }
      }
      bindKeys(upperCaseAlphabet);
      bindKeys(upperCaseAlphabet, 'Shift');
      bindKeys(upperCaseAlphabet, 'Ctrl');
      bindKeys(specialSymbols);
      bindKeys(specialSymbols, 'Ctrl');
      bindKeys(numbers);
      bindKeys(numbers, 'Ctrl');
      bindKeys(specialKeys);
      bindKeys(specialKeys, 'Ctrl');
      return cmToVimKeymap;
    }
function buildVimKeyMap ( ) { /**
       * Handle the raw key event from CodeMirror. Translate the
       * Shift + key modifier to the resulting letter, while preserving other
       * modifers.
       */ // TODO: Figure out a way to catch capslock. function cmKeyToVimKey ( key , modifier ) { var vimKey = key ; if ( isUpperCase ( vimKey ) ) { // Convert to lower case if shift is not the modifier since the key // we get from CodeMirror is always upper case. if ( modifier == 'Shift' ) { modifier = null ; } else { vimKey = vimKey . toLowerCase ( ) ; } } if ( modifier ) { // Vim will parse modifier+key combination as a single key. vimKey = modifier . charAt ( 0 ) + '-' + vimKey ; } var specialKey = ( { Enter : 'CR' , Backspace : 'BS' , Delete : 'Del' } ) [ vimKey ] ; vimKey = specialKey ? specialKey : vimKey ; vimKey = vimKey . length > 1 ? '<' + vimKey + '>' : vimKey ; return vimKey ; } // Closure to bind CodeMirror, key, modifier. function keyMapper ( vimKey ) { return function ( cm ) { CodeMirror . Vim . handleKey ( cm , vimKey ) ; } ; } var cmToVimKeymap = { 'nofallthrough' : true , 'style' : 'fat-cursor' } ; function bindKeys ( keys , modifier ) { for ( var i = 0 ; i < keys . length ; i ++ ) { var key = keys [ i ] ; if ( ! modifier && inArray ( key , specialSymbols ) ) { // Wrap special symbols with '' because that's how CodeMirror binds // them. key = "'" + key + "'" ; } var vimKey = cmKeyToVimKey ( keys [ i ] , modifier ) ; var cmKey = modifier ? modifier + '-' + key : key ; cmToVimKeymap [ cmKey ] = keyMapper ( vimKey ) ; } } bindKeys ( upperCaseAlphabet ) ; bindKeys ( upperCaseAlphabet , 'Shift' ) ; bindKeys ( upperCaseAlphabet , 'Ctrl' ) ; bindKeys ( specialSymbols ) ; bindKeys ( specialSymbols , 'Ctrl' ) ; bindKeys ( numbers ) ; bindKeys ( numbers , 'Ctrl' ) ; bindKeys ( specialKeys ) ; bindKeys ( specialKeys , 'Ctrl' ) ; return cmToVimKeymap ; }
Register Vim with CodeMirror
Register Vim with CodeMirror