2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00
fhem-mirror/fhem/www/codemirror/vim.js
2017-01-15 14:19:48 +00:00

147 lines
72 KiB
JavaScript

'use strict';var $jscomp={scope:{},findInternal:function(h,r,u){h instanceof String&&(h=String(h));for(var m=h.length,A=0;A<m;A++){var P=h[A];if(r.call(u,P,A,h))return{i:A,v:P}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(h,r,u){if(u.get||u.set)throw new TypeError("ES3 does not support getters and setters.");h!=Array.prototype&&h!=Object.prototype&&(h[r]=u.value)};
$jscomp.getGlobal=function(h){return"undefined"!=typeof window&&window===h?h:"undefined"!=typeof global&&null!=global?global:h};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(h,r,u,m){if(r){u=$jscomp.global;h=h.split(".");for(m=0;m<h.length-1;m++){var A=h[m];A in u||(u[A]={});u=u[A]}h=h[h.length-1];m=u[h];r=r(m);r!=m&&null!=r&&$jscomp.defineProperty(u,h,{configurable:!0,writable:!0,value:r})}};
$jscomp.polyfill("Array.prototype.find",function(h){return h?h:function(h,u){return $jscomp.findInternal(this,h,u).v}},"es6-impl","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(h){return $jscomp.SYMBOL_PREFIX+(h||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var h=$jscomp.global.Symbol.iterator;h||(h=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[h]&&$jscomp.defineProperty(Array.prototype,h,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(h){var r=0;return $jscomp.iteratorPrototype(function(){return r<h.length?{done:!1,value:h[r++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(h){$jscomp.initSymbolIterator();h={next:h};h[$jscomp.global.Symbol.iterator]=function(){return this};return h};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(h,r){$jscomp.initSymbolIterator();h instanceof String&&(h+="");var u=0,m={next:function(){if(u<h.length){var A=u++;return{value:r(A,h[A]),done:!1}}m.next=function(){return{done:!0,value:void 0}};return m.next()}};m[Symbol.iterator]=function(){return m};return m};
$jscomp.polyfill("Array.prototype.keys",function(h){return h?h:function(){return $jscomp.iteratorFromArray(this,function(h){return h})}},"es6-impl","es3");$jscomp.checkStringArgs=function(h,r,u){if(null==h)throw new TypeError("The 'this' value for String.prototype."+u+" must not be null or undefined");if(r instanceof RegExp)throw new TypeError("First argument to String.prototype."+u+" must not be a regular expression");return h+""};
$jscomp.polyfill("String.prototype.repeat",function(h){return h?h:function(h){var r=$jscomp.checkStringArgs(this,null,"repeat");if(0>h||1342177279<h)throw new RangeError("Invalid count value");h|=0;for(var m="";h;)if(h&1&&(m+=r),h>>>=1)r+=r;return m}},"es6-impl","es3");
(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],h):h(CodeMirror)})(function(h){var r=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",
type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},
{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",
toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",
motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},
{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",
motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",
motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},
{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,
inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",
motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,
matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},
context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},
isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",
motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},
context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},
{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",
type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",
isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",
isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},
context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",
action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,
backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,
querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},
{keys:":",type:"ex"}],u=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},
{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],m=h.Pos;h.Vim=function(){function A(a,b){this==h.keyMap.vim&&h.rmClass(a.getWrapperElement(),"cm-fat-cursor");b&&b.attach==P||(a.setOption("disableInput",!1),a.off("cursorActivity",wa),h.off(a.getInputField(),"paste",xa(a)),a.state.vim=null)}function P(a,b){this==h.keyMap.vim&&h.addClass(a.getWrapperElement(),"cm-fat-cursor");b&&b.attach==P||
(a.setOption("disableInput",!0),a.setOption("showCursorWhenSelecting",!1),h.signal(a,"vim-mode-change",{mode:"normal"}),a.on("cursorActivity",wa),ba(a),h.on(a.getInputField(),"paste",xa(a)))}function la(a,b){if(b){if(this[a])return this[a];a=eb(a);if(!a)return!1;var c=h.Vim.findKey(b,a);"function"==typeof c&&h.signal(b,"vim-keypress",a);return c}}function eb(a){if("'"==a.charAt(0))return a.charAt(1);a=a.split(/-(?!$)/);var b=a[a.length-1];if(1==a.length&&1==a[0].length||2==a.length&&"Shift"==a[0]&&
1==b.length)return!1;for(var c=!1,d=0;d<a.length;d++){var f=a[d];f in ya?a[d]=ya[f]:c=!0;f in za&&(a[d]=za[f])}if(!c)return!1;U(b)&&(a[a.length-1]=b.toLowerCase());return"<"+a.join("-")+">"}function xa(a){var b=a.state.vim;b.onPasteFn||(b.onPasteFn=function(){b.insertMode||(a.setCursor(B(a.getCursor(),0,1)),ca.enterInsertMode(a,{},b))});return b.onPasteFn}function ma(a,b){for(var c=[],d=a;d<a+b;d++)c.push(String.fromCharCode(d));return c}function Aa(a,b){return b>=a.firstLine()&&b<=a.lastLine()}function U(a){return/^[A-Z]$/.test(a)}
function na(a,b){for(var c=0;c<b.length;c++)if(b[c]==a)return!0;return!1}function da(a,b,c,d,f){if(void 0===b&&!f)throw Error("defaultValue is required unless callback is provided");c||(c="string");M[a]={type:c,defaultValue:b,callback:f};if(d)for(c=0;c<d.length;c++)M[d[c]]=M[a];b&&oa(a,b)}function oa(a,b,c,d){var f=M[a];d=d||{};d=d.scope;if(!f)throw Error("Unknown option: "+a);if("boolean"==f.type){if(b&&!0!==b)throw Error("Invalid argument: "+a+"="+b);!1!==b&&(b=!0)}f.callback?("local"!==d&&f.callback(b,
void 0),"global"!==d&&c&&f.callback(b,c)):("local"!==d&&(f.value="boolean"==f.type?!!b:b),"global"!==d&&c&&(c.state.vim.options[a]={value:b}))}function V(a,b,c){var d=M[a];c=c||{};c=c.scope;if(!d)throw Error("Unknown option: "+a);if(d.callback){a=b&&d.callback(void 0,b);if("global"!==c&&void 0!==a)return a;if("local"!==c)return d.callback()}else return a="global"!==c&&b&&b.state.vim.options[a],(a||"local"!==c&&d||{}).value}function Ba(){this.latestRegister=void 0;this.isRecording=this.isPlaying=!1;
this.replaySearchQueries=[];this.onRecordingDone=void 0;this.lastInsertModeChanges=Ca()}function ba(a){a.state.vim||(a.state.vim={inputState:new ea,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}});return a.state.vim}function Da(){p={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,
jumpList:fb(),macroModeState:new Ba,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Ea({}),searchHistoryController:new pa({}),exCommandHistoryController:new pa({})};for(var a in M){var b=M[a];b.value=b.defaultValue}}function ea(){this.prefixRepeat=[];this.motionRepeat=[];this.motionArgs=this.motion=this.operatorArgs=this.operator=null;this.keyBuffer=[];this.registerName=null}function F(a,b){a.state.vim.inputState=new ea;h.signal(a,"vim-command-done",b)}function H(a,
b,c){this.clear();this.keyBuffer=[a||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!b;this.blockwise=!!c}function Ea(a){this.registers=a;this.unnamedRegister=a['"']=new H;a["."]=new H;a[":"]=new H;a["/"]=new H}function pa(){this.historyBuffer=[];this.iterator=0;this.initialPrefix=null}function Fa(a,b){for(var c=[],d=0;d<b;d++)c.push(a);return c}function E(a,b,c){var d=Math.min(Math.max(a.firstLine(),b.line),a.lastLine());a=C(a,d)-1;return m(d,Math.min(Math.max(0,b.ch),c?a+1:a))}
function fa(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function B(a,b,c){"object"===typeof b&&(c=b.ch,b=b.line);return m(a.line+b,a.ch+c)}function gb(a,b){return{line:b.line-a.line,ch:b.line-a.line}}function Ga(a,b,c){return function(){for(var d=0;d<c;d++)b(a)}}function y(a){return m(a.line,a.ch)}function I(a,b){return a.ch==b.ch&&a.line==b.line}function x(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch?!0:!1}function G(a,b){2<arguments.length&&(b=G.apply(void 0,Array.prototype.slice.call(arguments,
1)));return x(a,b)?a:b}function T(a,b){2<arguments.length&&(b=T.apply(void 0,Array.prototype.slice.call(arguments,1)));return x(a,b)?b:a}function Ha(a,b,c){a=x(a,b);b=x(b,c);return a&&b}function C(a,b){return a.getLine(b).length}function qa(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function hb(a,b,c){var d=C(a,b);c=Array(c-d+1).join(" ");a.setCursor(m(b,d));a.replaceRange(c,a.getCursor())}function Ia(a,b){var c=[],d=a.listSelections(),f=y(a.clipPos(b)),e=!I(b,f),g;a:{var l=a.getCursor("head");
for(g=0;g<d.length;g++){var k=I(d[g].anchor,l),z=I(d[g].head,l);if(k||z)break a}g=-1}var l=I(d[g].head,d[g].anchor),k=d.length-1,h=k-g>g?k:0;g=d[h].anchor;var D=Math.min(g.line,f.line),k=Math.max(g.line,f.line),z=g.ch,f=f.ch,d=d[h].head.ch-z,h=f-z;0<d&&0>=h?(z++,e||f--):0>d&&0<=h?(z--,l||f++):0>d&&-1==h&&(z--,f++);for(e=D;e<=k;e++)d={anchor:new m(e,z),head:new m(e,f)},c.push(d);a.setSelections(c);b.ch=f;g.ch=z;return g}function Ja(a,b,c){for(var d=[],f=0;f<c;f++){var e=B(b,f,0);d.push({anchor:e,head:e})}a.setSelections(d,
0)}function ib(a,b){var c=b.lastSelection,d=function(){var b=a.getCursor(),d=a.getCursor(),g=c.visualBlock;if(g){for(var d=m(b.line+g.height,b.ch+g.width),g=[],l=b.line;l<d.line;l++){var k=m(l,b.ch),h=m(l,d.ch);g.push({anchor:k,head:h})}a.setSelections(g)}else l=c.anchorMark.find(),k=c.headMark.find(),g=k.line-l.line,l=k.ch-l.ch,d={line:d.line+g,ch:g?d.ch:l+d.ch},c.visualLine&&(b=m(b.line,0),d=m(d.line,C(a,d.line))),a.setSelection(b,d);return[b,d]};return b.visualMode?function(){var b=a.listSelections(),
c=b[0],b=b[b.length-1],c=x(c.anchor,c.head)?c.anchor:c.head,b=x(b.anchor,b.head)?b.head:b.anchor;return[c,b]}():d()}function Ka(a,b){var c=b.sel.anchor,d=b.sel.head;b.lastPastedText&&(d=a.posFromIndex(a.indexFromPos(c)+b.lastPastedText.length),b.lastPastedText=null);b.lastSelection={anchorMark:a.setBookmark(c),headMark:a.setBookmark(d),anchor:y(c),head:y(d),visualMode:b.visualMode,visualLine:b.visualLine,visualBlock:b.visualBlock}}function W(a,b,c){var d=a.state.vim;b=b||d.sel;c=c||d.visualLine?"line":
d.visualBlock?"block":"char";b=ra(a,b,c);a.setSelections(b.ranges,b.primary);La(a)}function ra(a,b,c,d){var f=y(b.head),e=y(b.anchor);if("char"==c)return f=d||x(b.head,b.anchor)?0:1,e=x(b.head,b.anchor)?1:0,f=B(b.head,0,f),e=B(b.anchor,0,e),{ranges:[{anchor:e,head:f}],primary:0};if("line"==c)return x(b.head,b.anchor)?(f.ch=0,e.ch=C(a,e.line)):(e.ch=0,b=a.lastLine(),f.line>b&&(f.line=b),f.ch=C(a,f.line)),{ranges:[{anchor:e,head:f}],primary:0};if("block"==c){b=Math.min(e.line,f.line);a=Math.min(e.ch,
f.ch);c=Math.max(e.ch,f.ch)+1;e=Math.max(e.line,f.line)-b+1;f=f.line==b?0:e-1;d=[];for(var g=0;g<e;g++)d.push({anchor:m(b+g,a),head:m(b+g,c)});return{ranges:d,primary:f}}}function J(a,b){var c=a.state.vim;!1!==b&&a.setCursor(E(a,c.sel.head));Ka(a,c);c.visualMode=!1;c.visualLine=!1;c.visualBlock=!1;h.signal(a,"vim-mode-change",{mode:"normal"});c.fakeCursor&&c.fakeCursor.clear()}function K(a){if(!a)return 0;var b=a.search(/\S/);return-1==b?a.length:b}function ga(a,b,c,d,f){c=a.getCursor("head");1==
a.getSelection().length&&(c=G(c,a.getCursor("anchor")));a=a.getLine(c.line);var e=c.ch;for(f=f?ha[0]:sa[0];!f(a.charAt(e));)if(e++,e>=a.length)return null;d?f=sa[0]:(f=ha[0],f(a.charAt(e))||(f=ha[1]));for(d=e;f(a.charAt(d))&&d<a.length;)d++;for(;f(a.charAt(e))&&0<=e;)e--;e++;if(b){for(b=d;/\s/.test(a.charAt(d))&&d<a.length;)d++;if(b==d){for(b=e;/\s/.test(a.charAt(e-1))&&0<e;)e--;e||(e=b)}}return{start:m(c.line,e),end:m(c.line,d)}}function Ma(a,b){p.lastCharacterSearch.increment=a;p.lastCharacterSearch.forward=
b.forward;p.lastCharacterSearch.selectedCharacter=b.selectedCharacter}function ta(a,b,c,d){for(var f=a.getCursor(),e=f.ch,g,l=0;l<b;l++){g=a.getLine(f.line);var k=d;g=c?g.indexOf(k,e+1):g.lastIndexOf(k,e-1);if(-1==g)return null;e=g}return m(a.getCursor().line,g)}function N(a,b,c,d){na(c,jb)&&(b.marks[c]&&b.marks[c].clear(),b.marks[c]=a.setBookmark(d))}function Na(a,b,c,d,f){function e(b,c,d){return d?!a.getLine(b)!=!a.getLine(b+c):!!a.getLine(b)&&!a.getLine(b+c)}b=b.line;var g=a.firstLine(),l=a.lastLine(),
k=b;if(d){for(;g<=k&&k<=l&&0<c;)e(k,d)&&c--,k+=d;return new m(k,0)}k=a.state.vim;k.visualLine&&e(b,1,!0)&&(k=k.sel.anchor,e(k.line,-1,!0)&&(f&&k.line==b||(b+=1)));d=!a.getLine(b);for(k=b;k<=l&&c;k++)e(k,1,!0)&&(f&&!a.getLine(k)==d||c--);c=new m(k,0);k>l&&!d?d=!0:f=!1;for(k=b;k>g&&(f&&!a.getLine(k)!=d&&k!=b||!e(k,-1,!0));k--);return{start:new m(k,0),end:c}}function Oa(){}function O(a){a=a.state.vim;return a.searchState_||(a.searchState_=new Oa)}function Pa(a){var b=Qa(a)||[];if(!b.length)return[];
var c=[];if(0===b[0]){for(var d=0;d<b.length;d++)"number"==typeof b[d]&&c.push(a.substring(b[d]+1,b[d+1]));return c}}function Qa(a){for(var b=!1,c=[],d=0;d<a.length;d++){var f=a.charAt(d);b||"/"!=f||c.push(d);b=!b&&"\\"==f}return c}function w(a,b){a.openNotification?a.openNotification('<span style="color: red">'+b+"</span>",{bottom:!0,duration:5E3}):alert(b)}function ia(a,b){var c=(b.prefix||"")+" "+(b.desc||""),d=b.desc,f='<span style="font-family: monospace; white-space: pre">'+(b.prefix||"")+'<input type="text"></span>';
d&&(f+=' <span style="color: #888">'+d+"</span>");d=b.onClose;a.openDialog?a.openDialog(f,d,{bottom:!0,value:b.value,onKeyDown:b.onKeyDown,onKeyUp:b.onKeyUp,selectValueOnOpen:!1}):d(prompt(c,""))}function X(a,b,c,d){if(b){var f=O(a),e;c=!!c;d=!!d;p.registerController.getRegister("/").setText(b);if(b instanceof RegExp)e=b;else{var g=Qa(b),l;g.length?(l=b.substring(0,g[0]),e=-1!=b.substring(g[0]).indexOf("i")):l=b;if(l){if(!V("pcre")){b=l;g=!1;l=[];for(var k=-1;k<b.length;k++){var h=b.charAt(k)||"",
q=b.charAt(k+1)||"",m=q&&-1!="|(){".indexOf(q);g?("\\"===h&&m||l.push(h),g=!1):"\\"===h?(g=!0,q&&-1!="}".indexOf(q)&&(m=!0),m&&"\\"!==q||l.push(h)):(l.push(h),m&&"\\"!==q&&l.push("\\"))}l=l.join("")}d&&(c=/^[^A-Z]*$/.test(l));e=new RegExp(l,c||e?"i":void 0)}else e=null}if(e){Ra(a,e);a:if(a=f.getQuery(),e instanceof RegExp&&a instanceof RegExp){c=["global","multiline","ignoreCase","source"];for(d=0;d<c.length;d++)if(b=c[d],e[b]!==a[b]){a=!1;break a}a=!0}else a=!1;if(a)return e;f.setQuery(e);return e}}}
function kb(a){if("^"==a.source.charAt(0))var b=!0;return{token:function(c){if(b&&!c.sol())c.skipToEnd();else{var d=c.match(a,!1);if(d){if(0==d[0].length)return c.next(),"searching";if(!c.sol()&&(c.backUp(1),!a.exec(c.next()+d[0])))return c.next(),null;c.match(a);return"searching"}for(;!c.eol()&&(c.next(),!c.match(a,!1)););}},query:a}}function Ra(a,b){var c=O(a),d=c.getOverlay();d&&b==d.query||(d&&a.removeOverlay(d),d=kb(b),a.addOverlay(d),a.showMatchesOnScrollbar&&(c.getScrollbarAnnotate()&&c.getScrollbarAnnotate().clear(),
c.setScrollbarAnnotate(a.showMatchesOnScrollbar(b))),c.setOverlay(d))}function Sa(a,b,c,d){void 0===d&&(d=1);return a.operation(function(){for(var f=a.getCursor(),e=a.getSearchCursor(c,f),g=0;g<d;g++){var l=e.find(b);0==g&&l&&I(e.from(),f)&&(l=e.find(b));if(!l&&(e=a.getSearchCursor(c,b?m(a.lastLine()):m(a.firstLine(),0)),!e.find(b)))return}return e.from()})}function ua(a){var b=O(a);a.removeOverlay(O(a).getOverlay());b.setOverlay(null);b.getScrollbarAnnotate()&&(b.getScrollbarAnnotate().clear(),b.setScrollbarAnnotate(null))}
function lb(a,b,c){"number"!=typeof a&&(a=a.line);return b instanceof Array?na(a,b):c?a>=b&&a<=c:a==b}function va(a){var b=a.getScrollInfo(),c=a.coordsChar({left:0,top:6+b.top},"local");a=a.coordsChar({left:0,top:b.clientHeight-10+b.top},"local");return{top:c.line,bottom:a.line}}function mb(a,b,c,d,f,e,g,l,k){function z(){a.operation(function(){for(;!p;)q(),m();n()})}function q(){var b=a.getRange(e.from(),e.to()).replace(g,l);e.replace(b)}function m(){for(;e.findNext()&&lb(e.from(),d,f);)if(c||!v||
e.from().line!=v.line){a.scrollIntoView(e.from(),30);a.setSelection(e.from(),e.to());v=e.from();p=!1;return}p=!0}function n(b){b&&b();a.focus();v&&(a.setCursor(v),b=a.state.vim,b.exMode=!1,b.lastHPos=b.lastHSPos=v.ch);k&&k()}a.state.vim.exMode=!0;var p=!1,v=e.from();m();p?w(a,"No matches for "+g.source):b?ia(a,{prefix:"replace with <strong>"+l+"</strong> (y/n/a/q/l)",onKeyDown:function(b,c,d){h.e_stop(b);switch(h.keyName(b)){case "Y":q();m();break;case "N":m();break;case "A":b=k;k=void 0;a.operation(z);
k=b;break;case "L":q();case "Q":case "Esc":case "Ctrl-C":case "Ctrl-[":n(d)}p&&n(d);return!0}}):(z(),k&&k())}function Y(a){var b=a.state.vim,c=p.macroModeState,d=p.registerController.getRegister("."),f=c.isPlaying,e=c.lastInsertModeChanges,g;if(!f){var l=e.inVisualBlock?b.lastSelection.visualBlock.height:1,k=e.changes;g=[];for(var z=0;z<k.length;)g.push(k[z]),k[z]instanceof ja?z++:z+=l;e.changes=g;a.off("change",Ta);h.off(a.getInputField(),"keydown",Ua)}!f&&1<b.insertModeRepeat&&(Va(a,b,b.insertModeRepeat-
1,!0),b.lastEditInputState.repeatOverride=b.insertModeRepeat);delete b.insertModeRepeat;b.insertMode=!1;a.setCursor(a.getCursor().line,a.getCursor().ch-1);a.setOption("keyMap","vim");a.setOption("disableInput",!0);a.toggleOverwrite(!1);d.setText(e.changes.join(""));h.signal(a,"vim-mode-change",{mode:"normal"});c.isRecording&&(c.isPlaying||(a=p.registerController.getRegister(c.latestRegister))&&a.pushInsertModeChanges&&a.pushInsertModeChanges(c.lastInsertModeChanges))}function Wa(a){r.unshift(a)}function Ta(a,
b){var c=p.macroModeState;a=c.lastInsertModeChanges;if(!c.isPlaying)for(;b;){a.expectCursorActivityForChange=!0;if("+input"==b.origin||"paste"==b.origin||void 0===b.origin)c=b.text.join("\n"),a.maybeReset&&(a.changes=[],a.maybeReset=!1),a.changes.push(c);b=b.next}}function wa(a){var b=a.state.vim;if(b.insertMode){var c=p.macroModeState;if(c.isPlaying)return;c=c.lastInsertModeChanges;c.expectCursorActivityForChange?c.expectCursorActivityForChange=!1:c.maybeReset=!0}else if(!a.curOp.isVimOp){var c=
a.getCursor("anchor"),d=a.getCursor("head");b.visualMode&&!a.somethingSelected()?J(a,!1):b.visualMode||b.insertMode||!a.somethingSelected()||(b.visualMode=!0,b.visualLine=!1,h.signal(a,"vim-mode-change",{mode:"visual"}));if(b.visualMode){var f=x(d,c)?0:-1,e=x(d,c)?-1:0,d=B(d,0,f),c=B(c,0,e);b.sel={anchor:c,head:d};N(a,b,"<",G(d,c));N(a,b,">",T(d,c))}else b.insertMode||(b.lastHPos=a.getCursor().ch)}b.visualMode&&La(a)}function La(a){var b=a.state.vim,c=E(a,y(b.sel.head)),d=B(c,0,1);b.fakeCursor&&b.fakeCursor.clear();
b.fakeCursor=a.markText(c,d,{className:"cm-animate-fat-cursor"})}function ja(a){this.keyName=a}function Ua(a){function b(){c.maybeReset&&(c.changes=[],c.maybeReset=!1);c.changes.push(new ja(d));return!0}var c=p.macroModeState.lastInsertModeChanges,d=h.keyName(a);d&&(-1==d.indexOf("Delete")&&-1==d.indexOf("Backspace")||h.lookupKey(d,"vim-insert",b))}function Va(a,b,c,d){function f(){l?R.processAction(a,b,b.lastEditActionCommand):R.evalInput(a,b)}function e(c){0<g.lastInsertModeChanges.changes.length&&
(c=b.lastEditActionCommand?c:1,Xa(a,g.lastInsertModeChanges.changes,c))}var g=p.macroModeState;g.isPlaying=!0;var l=!!b.lastEditActionCommand,k=b.inputState;b.inputState=b.lastEditInputState;if(l&&b.lastEditActionCommand.interlaceInsertRepeat)for(var h=0;h<c;h++)f(),e(1);else d||f(),e(c);b.inputState=k;b.insertMode&&!d&&Y(a);g.isPlaying=!1}function Xa(a,b,c){function d(b){if("string"==typeof b)h.commands[b](a);else b(a);return!0}var f=a.getCursor("head"),e=p.macroModeState.lastInsertModeChanges.inVisualBlock;
e&&(c=a.state.vim.lastSelection,c=gb(c.anchor,c.head),Ja(a,f,c.line+1),c=a.listSelections().length,a.setCursor(f));for(var g=0;g<c;g++){e&&a.setCursor(B(f,g,0));for(var l=0;l<b.length;l++){var k=b[l];if(k instanceof ja)h.lookupKey(k.keyName,"vim-insert",d);else{var z=a.getCursor();a.replaceRange(k,z,z)}}}e&&a.setCursor(B(f,0,1))}h.defineOption("vimMode",!1,function(a,b,c){b&&"vim"!=a.getOption("keyMap")?a.setOption("keyMap","vim"):!b&&c!=h.Init&&/^vim/.test(a.getOption("keyMap"))&&a.setOption("keyMap",
"default")});var ya={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},za={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"},nb=/[\d]/,ha=[h.isWordChar,function(a){return a&&!h.isWordChar(a)&&!/\s/.test(a)}],sa=[function(a){return/\S/.test(a)}],ka=ma(65,26),Z=ma(97,26),Ya=ma(48,10),jb=[].concat(ka,Z,Ya,["<",">"]),Za=[].concat(ka,Z,Ya,["-",'"',".",":","/"]),M={};da("filetype",void 0,"string",["ft"],function(a,b){if(void 0!==b){if(void 0===a)return a=b.getOption("mode"),"null"==a?"":a;b.setOption("mode",
""==a?"null":a)}});var fb=function(){var a=-1,b=0,c=0,d=Array(100);return{cachedCursor:void 0,add:function(f,e,g){function l(b){var c=++a%100,e=d[c];e&&e.clear();d[c]=f.setBookmark(b)}var k=d[a%100];k?(k=k.find())&&!I(k,e)&&l(e):l(e);l(g);b=a;c=a-100+1;0>c&&(c=0)},move:function(f,e){a+=e;a>b?a=b:a<c&&(a=c);var g=d[(100+a)%100];if(g&&!g.find()){e=0<e?1:-1;var l;f=f.getCursor();do if(a+=e,(g=d[(100+a)%100])&&(l=g.find())&&!I(f,l))break;while(a<b&&a>c)}return g}}},Ca=function(a){return a?{changes:a.changes,
expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};Ba.prototype={exitMacroRecordMode:function(){var a=p.macroModeState;if(a.onRecordingDone)a.onRecordingDone();a.onRecordingDone=void 0;a.isRecording=!1},enterMacroRecordMode:function(a,b){var c=p.registerController.getRegister(b);c&&(c.clear(),this.latestRegister=b,a.openDialog&&(this.onRecordingDone=a.openDialog("(recording)["+b+"]",null,{bottom:!0})),this.isRecording=!0)}};var p,aa,ka={buildKeyMap:function(){},
getRegisterController:function(){return p.registerController},resetVimGlobalState_:Da,getVimGlobalState_:function(){return p},maybeInitVimState_:ba,suppressErrorLogging:!1,InsertModeKey:ja,map:function(a,b,c){L.map(a,b,c)},unmap:function(a,b){L.unmap(a,b)},setOption:oa,getOption:V,defineOption:da,defineEx:function(a,b,c){if(!b)b=a;else if(0!==a.indexOf(b))throw Error('(Vim.defineEx) "'+b+'" is not a prefix of "'+a+'", command not registered');$a[a]=c;L.commandMap_[b]={name:a,shortName:b,type:"api"}},
handleKey:function(a,b,c){a=this.findKey(a,b,c);if("function"===typeof a)return a()},findKey:function(a,b,c){function d(){if("<Esc>"==b)return F(a),g.visualMode?J(a):g.insertMode&&Y(a),!0}function f(){if(d())return!0;for(var c=g.inputState.keyBuffer+=b,e=1==b.length,f=R.matchCommand(c,r,g.inputState,"insert");1<c.length&&"full"!=f.type;){var c=g.inputState.keyBuffer=c.slice(1),l=R.matchCommand(c,r,g.inputState,"insert");"none"!=l.type&&(f=l)}if("none"==f.type)return F(a),!1;if("partial"==f.type)return aa&&
window.clearTimeout(aa),aa=window.setTimeout(function(){g.insertMode&&g.inputState.keyBuffer&&F(a)},V("insertModeEscKeysTimeout")),!e;aa&&window.clearTimeout(aa);if(e){e=a.listSelections();for(l=0;l<e.length;l++){var h=e[l].head;a.replaceRange("",B(h,0,-(c.length-1)),h,"+input")}p.macroModeState.lastInsertModeChanges.changes.pop()}F(a);return f.command}function e(){var e;a:{var f=p.macroModeState;if(f.isRecording){if("q"==b){f.exitMacroRecordMode();F(a);e=!0;break a}"mapping"!=c&&(e=b,f.isPlaying||
(f=p.registerController.getRegister(f.latestRegister))&&f.pushText(e))}e=void 0}if(e||d())return!0;e=g.inputState.keyBuffer+=b;if(/^[1-9]\d*$/.test(e))return!0;f=/^(\d*)(.*)$/.exec(e);if(!f)return F(a),!1;var l=R.matchCommand(f[2]||f[1],r,g.inputState,g.visualMode?"visual":"normal");if("none"==l.type)return F(a),!1;if("partial"==l.type)return!0;g.inputState.keyBuffer="";f=/^(\d*)(.*)$/.exec(e);f[1]&&"0"!=f[1]&&g.inputState.pushRepeatDigit(f[1]);return l.command}var g=ba(a),l;l=g.insertMode?f():e();
if(!1!==l)return!0===l?function(){return!0}:function(){return a.operation(function(){a.curOp.isVimOp=!0;try{if("keyToKey"==l.type)for(var c=l.toKeys,d;c;)d=/<\w+-.+?>|<\w+>|./.exec(c),b=d[0],c=c.substring(d.index+b.length),h.Vim.handleKey(a,b,"mapping");else R.processCommand(a,g,l)}catch(q){throw a.state.vim=void 0,ba(a),h.Vim.suppressErrorLogging||console.log(q),q;}return!0})}},handleEx:function(a,b){L.processCommand(a,b)},defineMotion:function(a,b){S[a]=b},defineAction:function(a,b){ca[a]=b},defineOperator:function(a,
b){ab[a]=b},mapCommand:function(a,b,c,d,f){a={keys:a,type:b};a[b]=c;a[b+"Args"]=d;for(var e in f)a[e]=f[e];Wa(a)},_mapCommand:Wa,defineRegister:function(a,b){var c=p.registerController.registers[a];if(!a||1!=a.length)throw Error("Register name must be 1 character");if(c[a])throw Error("Register already defined "+a);c[a]=b;Za.push(a)},exitVisualMode:J,exitInsertMode:Y};ea.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)};
ea.prototype.getRepeat=function(){var a=0;if(0<this.prefixRepeat.length||0<this.motionRepeat.length)a=1,0<this.prefixRepeat.length&&(a*=parseInt(this.prefixRepeat.join(""),10)),0<this.motionRepeat.length&&(a*=parseInt(this.motionRepeat.join(""),10));return a};H.prototype={setText:function(a,b,c){this.keyBuffer=[a||""];this.linewise=!!b;this.blockwise=!!c},pushText:function(a,b){b&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0);this.keyBuffer.push(a)},pushInsertModeChanges:function(a){this.insertModeChanges.push(Ca(a))},
pushSearchQuery:function(a){this.searchQueries.push(a)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!1},toString:function(){return this.keyBuffer.join("")}};Ea.prototype={pushText:function(a,b,c,d,f){d&&"\n"==c.charAt(0)&&(c=c.slice(1)+"\n");d&&"\n"!==c.charAt(c.length-1)&&(c+="\n");var e=this.isValidRegister(a)?this.getRegister(a):null;if(e)U(a)?e.pushText(c,d):e.setText(c,d,f),this.unnamedRegister.setText(e.toString(),d);else{switch(b){case "yank":this.registers["0"]=
new H(c,d,f);break;case "delete":case "change":-1==c.indexOf("\n")?this.registers["-"]=new H(c,d):(this.shiftNumericRegisters_(),this.registers["1"]=new H(c,d))}this.unnamedRegister.setText(c,d,f)}},getRegister:function(a){if(!this.isValidRegister(a))return this.unnamedRegister;a=a.toLowerCase();this.registers[a]||(this.registers[a]=new H);return this.registers[a]},isValidRegister:function(a){return a&&na(a,Za)},shiftNumericRegisters_:function(){for(var a=9;2<=a;a--)this.registers[a]=this.getRegister(""+
(a-1))}};pa.prototype={nextMatch:function(a,b){var c=this.historyBuffer,d=b?-1:1;null===this.initialPrefix&&(this.initialPrefix=a);for(var f=this.iterator+d;b?0<=f:f<c.length;f+=d)for(var e=c[f],g=0;g<=e.length;g++)if(this.initialPrefix==e.substring(0,g))return this.iterator=f,e;if(f>=c.length)return this.iterator=c.length,this.initialPrefix;if(0>f)return a},pushInput:function(a){var b=this.historyBuffer.indexOf(a);-1<b&&this.historyBuffer.splice(b,1);a.length&&this.historyBuffer.push(a)},reset:function(){this.initialPrefix=
null;this.iterator=this.historyBuffer.length}};var R={matchCommand:function(a,b,c,d){var f,e,g=[];f=[];for(var l=0;l<b.length;l++){var k=b[l],h;if(h=!("insert"==d&&"insert"!=k.context||k.context&&k.context!=d||c.operator&&"action"==k.type)){e=a;var m=k.keys;if("<character>"==m.slice(-11)){h=m.length-11;var p=e.slice(0,h),m=m.slice(0,h);e=p==m&&e.length>h?"full":0==m.indexOf(p)?"partial":!1}else e=e==m?"full":0==m.indexOf(e)?"partial":!1;h=e}h&&("partial"==e&&g.push(k),"full"==e&&f.push(k))}b=g.length&&
g;f=f.length&&f;if(!f&&!b)return{type:"none"};if(!f&&b)return{type:"partial"};var n;for(b=0;b<f.length;b++)d=f[b],n||(n=d);if("<character>"==n.keys.slice(-11)){a=(f=/^.*(<[\w\-]+>)$/.exec(a))?f[1]:a.slice(-1);if(1<a.length)switch(a){case "<CR>":a="\n";break;case "<Space>":a=" "}c.selectedCharacter=a}return{type:"full",command:n}},processCommand:function(a,b,c){b.inputState.repeatOverride=c.repeatOverride;switch(c.type){case "motion":this.processMotion(a,b,c);break;case "operator":this.processOperator(a,
b,c);break;case "operatorMotion":this.processOperatorMotion(a,b,c);break;case "action":this.processAction(a,b,c);break;case "search":this.processSearch(a,b,c);break;case "ex":case "keyToEx":this.processEx(a,b,c)}},processMotion:function(a,b,c){b.inputState.motion=c.motion;b.inputState.motionArgs=fa(c.motionArgs);this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator){d.motion="expandToLine";d.motionArgs={linewise:!0};this.evalInput(a,b);return}F(a)}d.operator=
c.operator;d.operatorArgs=fa(c.operatorArgs);b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,f=fa(c.operatorMotionArgs);f&&d&&f.visualLine&&(b.visualLine=!0);this.processOperator(a,b,c);d||this.processMotion(a,b,c)},processAction:function(a,b,c){var d=b.inputState,f=d.getRepeat(),e=!!f,g=fa(c.actionArgs)||{};d.selectedCharacter&&(g.selectedCharacter=d.selectedCharacter);c.operator&&this.processOperator(a,b,c);c.motion&&this.processMotion(a,b,c);(c.motion||
c.operator)&&this.evalInput(a,b);g.repeat=f||1;g.repeatIsExplicit=e;g.registerName=d.registerName;F(a);b.lastMotion=null;c.isEdit&&this.recordLastEdit(b,d,c);ca[c.action](a,g,b)},processSearch:function(a,b,c){function d(d,e,f){p.searchHistoryController.pushInput(d);p.searchHistoryController.reset();try{X(a,d,e,f)}catch(Q){w(a,"Invalid regex: "+d);F(a);return}R.processMotion(a,b,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:c.searchArgs.toJumplist}})}function f(b){a.scrollTo(D.left,
D.top);d(b,!0,!0);var c=p.macroModeState;c.isRecording&&(c.isPlaying||(c=p.registerController.getRegister(c.latestRegister))&&c.pushSearchQuery&&c.pushSearchQuery(b))}function e(b,c,d){b=h.keyName(b);"Up"==b||"Down"==b?(c=p.searchHistoryController.nextMatch(c,"Up"==b?!0:!1)||"",d(c)):"Left"!=b&&"Right"!=b&&"Ctrl"!=b&&"Alt"!=b&&"Shift"!=b&&p.searchHistoryController.reset();var e;try{e=X(a,c,!0,!0)}catch(qb){}e?a.scrollIntoView(Sa(a,!l,e),30):(ua(a),a.scrollTo(D.left,D.top))}function g(b,c,d){var e=
h.keyName(b);"Esc"==e||"Ctrl-C"==e||"Ctrl-["==e||"Backspace"==e&&""==c?(p.searchHistoryController.pushInput(c),p.searchHistoryController.reset(),X(a,q),ua(a),a.scrollTo(D.left,D.top),h.e_stop(b),F(a),d(),a.focus()):"Ctrl-U"==e&&(h.e_stop(b),d(""))}if(a.getSearchCursor){var l=c.searchArgs.forward,k=c.searchArgs.wholeWordOnly;O(a).setReversed(!l);var m=l?"/":"?",q=O(a).getQuery(),D=a.getScrollInfo();switch(c.searchArgs.querySrc){case "prompt":k=p.macroModeState;k.isPlaying?(m=k.replaySearchQueries.shift(),
d(m,!0,!1)):ia(a,{onClose:f,prefix:m,desc:ob,onKeyUp:e,onKeyDown:g});break;case "wordUnderCursor":var n=ga(a,!1,!0,!1,!0),t=!0;n||(n=ga(a,!1,!0,!1,!1),t=!1);n&&(m=a.getLine(n.start.line).substring(n.start.ch,n.end.ch),m=t&&k?"\\b"+m+"\\b":m.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),p.jumpList.cachedCursor=a.getCursor(),a.setCursor(n.start),d(m,!0,!1))}}},processEx:function(a,b,c){function d(b){p.exCommandHistoryController.pushInput(b);p.exCommandHistoryController.reset();L.processCommand(a,b)}function f(b,
c,d){var e=h.keyName(b);if("Esc"==e||"Ctrl-C"==e||"Ctrl-["==e||"Backspace"==e&&""==c)p.exCommandHistoryController.pushInput(c),p.exCommandHistoryController.reset(),h.e_stop(b),F(a),d(),a.focus();"Up"==e||"Down"==e?(c=p.exCommandHistoryController.nextMatch(c,"Up"==e?!0:!1)||"",d(c)):"Ctrl-U"==e?(h.e_stop(b),d("")):"Left"!=e&&"Right"!=e&&"Ctrl"!=e&&"Alt"!=e&&"Shift"!=e&&p.exCommandHistoryController.reset()}"keyToEx"==c.type?L.processCommand(a,c.exArgs.input):b.visualMode?ia(a,{onClose:d,prefix:":",
value:"'<,'>",onKeyDown:f}):ia(a,{onClose:d,prefix:":",onKeyDown:f})},evalInput:function(a,b){var c=b.inputState,d=c.motion,f=c.motionArgs||{},e=c.operator,g=c.operatorArgs||{},l=c.registerName,k=b.sel,h=y(b.visualMode?E(a,k.head):a.getCursor("head")),q=y(b.visualMode?E(a,k.anchor):a.getCursor("anchor")),D=y(h),q=y(q),n,t,v;e&&this.recordLastEdit(b,c);v=void 0!==c.repeatOverride?c.repeatOverride:c.getRepeat();if(0<v&&f.explicitRepeat)f.repeatIsExplicit=!0;else if(f.noRepeat||!f.explicitRepeat&&0===
v)v=1,f.repeatIsExplicit=!1;c.selectedCharacter&&(f.selectedCharacter=g.selectedCharacter=c.selectedCharacter);f.repeat=v;F(a);if(d){n=S[d](a,h,f,b);b.lastMotion=S[d];if(!n)return;f.toJumplist&&(d=p.jumpList,(c=d.cachedCursor)?(I(c,n)||p.jumpList.add(a,c,n),delete d.cachedCursor):I(h,n)||p.jumpList.add(a,h,n));n instanceof Array&&(t=n[0],n=n[1]);n||(n=y(h));b.visualMode?(b.visualBlock&&Infinity===n.ch||(n=E(a,n,b.visualBlock)),t&&(t=E(a,t,!0)),t=t||q,k.anchor=t,k.head=n,W(a),N(a,b,"<",x(t,n)?t:n),
N(a,b,">",x(t,n)?n:t)):e||(n=E(a,n),a.setCursor(n.line,n.ch))}if(e){g.lastSel?(t=q,k=g.lastSel,n=Math.abs(k.head.line-k.anchor.line),h=Math.abs(k.head.ch-k.anchor.ch),n=k.visualLine?m(q.line+n,q.ch):k.visualBlock?m(q.line+n,q.ch+h):k.head.line==k.anchor.line?m(q.line,q.ch+h):m(q.line+n,q.ch),b.visualMode=!0,b.visualLine=k.visualLine,b.visualBlock=k.visualBlock,k=b.sel={anchor:t,head:n},W(a)):b.visualMode&&(g.lastSel={anchor:y(k.anchor),head:y(k.head),visualBlock:b.visualBlock,visualLine:b.visualLine});
if(b.visualMode){if(t=G(k.head,k.anchor),k=T(k.head,k.anchor),D=b.visualLine||g.linewise,f=b.visualBlock?"block":D?"line":"char",t=ra(a,{anchor:t,head:k},f),D)if(k=t.ranges,"block"==f)for(f=0;f<k.length;f++)k[f].head.ch=C(a,k[f].head.line);else"line"==f&&(k[0].head=m(k[0].head.line+1,0))}else{t=y(t||q);k=y(n||D);x(k,t)&&(D=t,t=k,k=D);if(D=f.linewise||g.linewise)h=k,t.ch=0,h.ch=0,h.line++;else if(f.forward&&(h=k,d=a.getRange(t,h),/\n\s*$/.test(d))){d=d.split("\n");d.pop();for(c=d.pop();0<d.length&&
c&&/^\s*$/.test(c);c=d.pop())h.line--,h.ch=0;c?(h.line--,h.ch=C(a,h.line)):h.ch=0}t=ra(a,{anchor:t,head:k},"char",!f.inclusive||D)}a.setSelections(t.ranges,t.primary);b.lastMotion=null;g.repeat=v;g.registerName=l;g.linewise=D;e=ab[e](a,g,t.ranges,q,n);b.visualMode&&J(a,null!=e);e&&a.setCursor(e)}},recordLastEdit:function(a,b,c){var d=p.macroModeState;d.isPlaying||(a.lastEditInputState=b,a.lastEditActionCommand=c,d.lastInsertModeChanges.changes=[],d.lastInsertModeChanges.expectCursorActivityForChange=
!1)}},S={moveToTopLine:function(a,b,c){b=va(a).top+c.repeat-1;return m(b,K(a.getLine(b)))},moveToMiddleLine:function(a){var b=va(a),b=Math.floor(.5*(b.top+b.bottom));return m(b,K(a.getLine(b)))},moveToBottomLine:function(a,b,c){b=va(a).bottom-c.repeat+1;return m(b,K(a.getLine(b)))},expandToLine:function(a,b,c){return m(b.line+c.repeat-1,Infinity)},findNext:function(a,b,c){b=O(a);var d=b.getQuery();if(d){var f=!c.forward,f=b.isReversed()?!f:f;Ra(a,d);return Sa(a,f,d,c.repeat)}},goToMark:function(a,
b,c,d){return(b=d.marks[c.selectedCharacter])?(b=b.find(),c.linewise?{line:b.line,ch:K(a.getLine(b.line))}:b):null},moveToOtherHighlightedEnd:function(a,b,c,d){return d.visualBlock&&c.sameLine?(b=d.sel,[E(a,m(b.anchor.line,b.head.ch)),E(a,m(b.head.line,b.anchor.ch))]):[d.sel.head,d.sel.anchor]},jumpToMark:function(a,b,c,d){for(var f=0;f<c.repeat;f++){var e=b,g;for(g in d.marks)if(/^[a-z]$/.test(g)){var l=d.marks[g].find();if(c.forward?!x(l,e):!x(e,l))if(!c.linewise||l.line!=e.line){var k=I(e,b),h=
c.forward?Ha(e,l,b):Ha(b,l,e);if(k||h)b=l}}}c.linewise&&(b=m(b.line,K(a.getLine(b.line))));return b},moveByCharacters:function(a,b,c){a=c.repeat;return m(b.line,c.forward?b.ch+a:b.ch-a)},moveByLines:function(a,b,c,d){var f=b.ch;switch(d.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:f=d.lastHPos;break;default:d.lastHPos=f}var e=c.repeat+(c.repeatOffset||0),e=c.forward?b.line+e:b.line-e,g=a.firstLine(),l=a.lastLine();
if(e<g&&b.line==g)return this.moveToStartOfLine(a,b,c,d);if(e>l&&b.line==l)return this.moveToEol(a,b,c,d);c.toFirstChar&&(f=K(a.getLine(e)),d.lastHPos=f);d.lastHSPos=a.charCoords(m(e,f),"div").left;return m(e,f)},moveByDisplayLines:function(a,b,c,d){switch(d.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:d.lastHSPos=a.charCoords(b,"div").left}var f=c.repeat;b=a.findPosV(b,c.forward?f:-f,"line",d.lastHSPos);
b.hitSide&&(c.forward?c={top:a.charCoords(b,"div").top+8,left:d.lastHSPos}:(c=a.charCoords(m(a.firstLine(),0),"div"),c.left=d.lastHSPos),b=a.coordsChar(c,"div"));d.lastHPos=b.ch;return b},moveByPage:function(a,b,c){var d=c.repeat;return a.findPosV(b,c.forward?d:-d,"page")},moveByParagraph:function(a,b,c){return Na(a,b,c.repeat,c.forward?1:-1)},moveByScroll:function(a,b,c,d){var f=a.getScrollInfo(),e=c.repeat;e||(e=f.clientHeight/(2*a.defaultTextHeight()));var g=a.charCoords(b,"local");c.repeat=e;
b=S.moveByDisplayLines(a,b,c,d);if(!b)return null;c=a.charCoords(b,"local");a.scrollTo(null,f.top+c.top-g.top);return b},moveByWords:function(a,b,c){var d=b,f=c.repeat;b=!!c.forward;var e=!!c.wordEnd,g=!!c.bigWord;c=y(d);var l=[];(b&&!e||!b&&e)&&f++;for(var k=!(b&&e),h=0;h<f;h++){var q;b:{q=a;var p=b,n=g,t=k,v=d.line,r=d.ch,u=q.getLine(v),Q=p?1:-1,n=n?sa:ha;if(t&&""==u){v+=Q;u=q.getLine(v);if(!Aa(q,v)){q=null;break b}r=p?0:u.length}for(;;){if(t&&""==u){q={from:0,to:0,line:v};break b}for(var p=0<Q?
u.length:-1,w,x;r!=p;){for(var A=!1,B=0;B<n.length&&!A;++B)if(n[B](u.charAt(r))){for(w=r;r!=p&&n[B](u.charAt(r));)r+=Q;x=r;A=w!=x;if(w!=d.ch||v!=d.line||x!=w+Q){q={from:Math.min(w,x+1),to:Math.max(w,x),line:v};break b}}A||(r+=Q)}v+=Q;if(!Aa(q,v)){q=null;break b}u=q.getLine(v);r=0<Q?0:u.length}}if(!q){g=C(a,a.lastLine());l.push(b?{line:a.lastLine(),from:g,to:g}:{line:0,from:0,to:0});break}l.push(q);d=m(q.line,b?q.to-1:q.from)}a=l.length!=f;f=l[0];g=l.pop();b&&!e?(a||f.from==c.ch&&f.line==c.line||(g=
l.pop()),b=m(g.line,g.from)):b&&e?b=m(g.line,g.to-1):!b&&e?(a||f.to==c.ch&&f.line==c.line||(g=l.pop()),b=m(g.line,g.to)):b=m(g.line,g.from);return b},moveTillCharacter:function(a,b,c){a=ta(a,c.repeat,c.forward,c.selectedCharacter);b=c.forward?-1:1;Ma(b,c);if(!a)return null;a.ch+=b;return a},moveToCharacter:function(a,b,c){var d=c.repeat;Ma(0,c);return ta(a,d,c.forward,c.selectedCharacter)||b},moveToSymbol:function(a,b,c){var d=c.repeat,f=c.forward,e=c.selectedCharacter;c=y(a.getCursor());var g=f?
1:-1,l=f?a.lineCount():-1,k=c.ch,h=c.line,q=a.getLine(h),f={lineText:q,nextCh:q.charAt(k),lastCh:null,index:k,symb:e,reverseSymb:(f?{")":"(","}":"{"}:{"(":")","{":"}"})[e],forward:f,depth:0,curMoveThrough:!1};if(k=pb[e]){e=bb[k].init;k=bb[k].isComplete;for(e&&e(f);h!==l&&d;)f.index+=g,f.nextCh=f.lineText.charAt(f.index),f.nextCh||(h+=g,f.lineText=a.getLine(h)||"",0<g?f.index=0:(e=f.lineText.length,f.index=0<e?e-1:0),f.nextCh=f.lineText.charAt(f.index)),k(f)&&(c.line=h,c.ch=f.index,d--);a=f.nextCh||
f.curMoveThrough?m(h,f.index):c}else a=c;return a||b},moveToColumn:function(a,b,c,d){c=c.repeat;d.lastHPos=c-1;d.lastHSPos=a.charCoords(b,"div").left;b=a.getCursor().line;return E(a,m(b,c-1))},moveToEol:function(a,b,c,d){d.lastHPos=Infinity;b=m(b.line+c.repeat-1,Infinity);c=a.clipPos(b);c.ch--;d.lastHSPos=a.charCoords(c,"div").left;return b},moveToFirstNonWhiteSpaceCharacter:function(a,b){return m(b.line,K(a.getLine(b.line)))},moveToMatchedSymbol:function(a,b){var c=b.line,d=b.ch,f=a.getLine(c),e;
do if((e=f.charAt(d++))&&-1!="()[]{}".indexOf(e)){var g=a.getTokenTypeAt(m(c,d));if("string"!==g&&"comment"!==g)break}while(e);return e?a.findMatchingBracket(m(c,d)).to:b},moveToStartOfLine:function(a,b){return m(b.line,0)},moveToLineOrEdgeOfDocument:function(a,b,c){b=c.forward?a.lastLine():a.firstLine();c.repeatIsExplicit&&(b=c.repeat-a.getOption("firstLineNumber"));return m(b,K(a.getLine(b)))},textObjectManipulation:function(a,b,c,d){var f={"'":!0,'"':!0},e=c.selectedCharacter;"b"==e?e="(":"B"==
e&&(e="{");var g=!c.textObjectInner;if({"(":")",")":"(","{":"}","}":"{","[":"]","]":"["}[e]){var l,k;k={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[e];l={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[e];c=a.getLine(b.line).charAt(b.ch)===l?1:0;l=a.scanForBracket(m(b.line,b.ch+c),-1,null,{bracketRegex:k});k=a.scanForBracket(m(b.line,b.ch+c),1,null,{bracketRegex:k});if(l&&k){l=l.pos;k=k.pos;if(l.line==k.line&&l.ch>k.ch||l.line>k.line)b=l,l=k,k=b;g?k.ch+=1:l.ch+=1;b={start:l,
end:k}}else b={start:b,end:b}}else if(f[e]){c=e;b=y(b);d=a.getLine(b.line).split("");e=d.indexOf(c);b.ch<e?b.ch=e:e<b.ch&&d[b.ch]==c&&(k=b.ch,--b.ch);if(d[b.ch]!=c||k)for(e=b.ch;-1<e&&!l;e--)d[e]==c&&(l=e+1);else l=b.ch+1;if(l&&!k)for(e=l,f=d.length;e<f&&!k;e++)d[e]==c&&(k=e);l&&k?(g&&(--l,++k),b={start:m(b.line,l),end:m(b.line,k)}):b={start:b,end:b}}else if("W"===e)b=ga(a,g,!0,!0);else if("w"===e)b=ga(a,g,!0,!1);else if("p"===e)if(b=Na(a,b,c.repeat,0,g),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=
!0);else{if(g=d.inputState.operatorArgs)g.linewise=!0;b.end.line--}else return null;return a.state.vim.visualMode?(g=b.start,b=b.end,k=a.state.vim.sel,l=k.head,k=k.anchor,x(b,g)&&(c=b,b=g,g=c),x(l,k)?(l=G(g,l),k=T(k,b)):(k=G(g,k),l=T(l,b),l=B(l,0,-1),-1==l.ch&&l.line!=a.firstLine()&&(l=m(l.line-1,C(a,l.line-1)))),[k,l]):[b.start,b.end]},repeatLastCharacterSearch:function(a,b,c){var d=p.lastCharacterSearch,f=c.repeat,e=c.forward===d.forward,g=(d.increment?1:0)*(e?-1:1);a.moveH(-g,"char");c.inclusive=
e?!0:!1;c=ta(a,f,e,d.selectedCharacter);if(!c)return a.moveH(g,"char"),b;c.ch+=g;return c}},ab={change:function(a,b,c){var d,f,e=a.state.vim;p.macroModeState.lastInsertModeChanges.inVisualBlock=e.visualBlock;if(e.visualMode)f=a.getSelection(),d=Fa("",c.length),a.replaceSelections(d),d=G(c[0].head,c[0].anchor);else{d=c[0].anchor;var g=c[0].head;f=a.getRange(d,g);e=e.lastEditInputState||{};if("moveByWords"==e.motion&&!/^\s*$/.test(f)){var l=/\s+$/.exec(f);l&&e.motionArgs&&e.motionArgs.forward&&(g=B(g,
0,-l[0].length),f=f.slice(0,-l[0].length))}e=new m(d.line-1,Number.MAX_VALUE);l=a.firstLine()==a.lastLine();g.line>a.lastLine()&&b.linewise&&!l?a.replaceRange("",e,g):a.replaceRange("",d,g);b.linewise&&(l||(a.setCursor(e),h.commands.newlineAndIndent(a)),d.ch=Number.MAX_VALUE)}p.registerController.pushText(b.registerName,"change",f,b.linewise,1<c.length);ca.enterInsertMode(a,{head:d},a.state.vim)},"delete":function(a,b,c){var d,f=a.state.vim;if(f.visualBlock){d=a.getSelection();var e=Fa("",c.length);
a.replaceSelections(e);c=c[0].anchor}else e=c[0].anchor,c=c[0].head,b.linewise&&c.line!=a.firstLine()&&e.line==a.lastLine()&&e.line==c.line-1&&(e.line==a.firstLine()?e.ch=0:e=m(e.line-1,C(a,e.line-1))),d=a.getRange(e,c),a.replaceRange("",e,c),c=e,b.linewise&&(c=S.moveToFirstNonWhiteSpaceCharacter(a,e));p.registerController.pushText(b.registerName,"delete",d,b.linewise,f.visualBlock);return E(a,c)},indent:function(a,b,c){var d=a.state.vim,f=c[0].anchor.line,e=d.visualBlock?c[c.length-1].anchor.line:
c[0].head.line,d=d.visualMode?b.repeat:1;for(b.linewise&&e--;f<=e;f++)for(var g=0;g<d;g++)a.indentLine(f,b.indentRight);return S.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},changeCase:function(a,b,c,d,f){for(var e=a.getSelections(),g=[],l=b.toLower,k=0;k<e.length;k++){var h=e[k],m="";if(!0===l)m=h.toLowerCase();else if(!1===l)m=h.toUpperCase();else for(var p=0;p<h.length;p++)var n=h.charAt(p),m=m+(U(n)?n.toLowerCase():n.toUpperCase());g.push(m)}a.replaceSelections(g);return b.shouldMoveCursor?
f:!a.state.vim.visualMode&&b.linewise&&c[0].anchor.line+1==c[0].head.line?S.moveToFirstNonWhiteSpaceCharacter(a,d):b.linewise?d:G(c[0].anchor,c[0].head)},yank:function(a,b,c,d){var f=a.state.vim;a=a.getSelection();c=f.visualMode?G(f.sel.anchor,f.sel.head,c[0].head,c[0].anchor):d;p.registerController.pushText(b.registerName,"yank",a,b.linewise,f.visualBlock);return c}},ca={jumpListWalk:function(a,b,c){c.visualMode||(c=b.repeat,b=(b=(b=p.jumpList.move(a,b.forward?c:-c))?b.find():void 0)?b:a.getCursor(),
a.setCursor(b))},scroll:function(a,b,c){if(!c.visualMode){var d=b.repeat||1;c=a.defaultTextHeight();var f=a.getScrollInfo().top,d=c*d,f=b.forward?f+d:f-d,d=y(a.getCursor()),e=a.charCoords(d,"local");b.forward?f>e.top?(d.line+=(f-e.top)/c,d.line=Math.ceil(d.line),a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,e.top)):a.scrollTo(null,f):(b=f+a.getScrollInfo().clientHeight,b<e.bottom?(d.line-=(e.bottom-b)/c,d.line=Math.floor(d.line),a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,
e.bottom-a.getScrollInfo().clientHeight)):a.scrollTo(null,f))}},scrollToCursor:function(a,b){var c=a.getCursor().line,d=a.charCoords(m(c,0),"local"),c=a.getScrollInfo().clientHeight,f=d.top,d=d.bottom-f;switch(b.position){case "center":f=f-c/2+d;break;case "bottom":f=f-c+d}a.scrollTo(null,f)},replayMacro:function(a,b,c){var d=b.selectedCharacter;b=b.repeat;var f=p.macroModeState;"@"==d&&(d=f.latestRegister);for(;b--;){var e=a,g=c,l=f,k=d,m=p.registerController.getRegister(k);if(":"==k)m.keyBuffer[0]&&
L.processCommand(e,m.keyBuffer[0]);else{var k=m.keyBuffer,q=0;l.isPlaying=!0;l.replaySearchQueries=m.searchQueries.slice(0);for(var r=0;r<k.length;r++)for(var n=k[r],t,v;n;)t=/<\w+-.+?>|<\w+>|./.exec(n),v=t[0],n=n.substring(t.index+v.length),h.Vim.handleKey(e,v,"macro"),g.insertMode&&(t=m.insertModeChanges[q++].changes,p.macroModeState.lastInsertModeChanges.changes=t,Xa(e,t,1),Y(e))}l.isPlaying=!1}},enterMacroRecordMode:function(a,b){p.macroModeState.enterMacroRecordMode(a,b.selectedCharacter)},toggleOverwrite:function(a){a.state.overwrite?
(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),h.signal(a,"vim-mode-change",{mode:"insert"})):(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),h.signal(a,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(a,b,c){if(!a.getOption("readOnly")){c.insertMode=!0;c.insertModeRepeat=b&&b.repeat||1;var d=b?b.insertAt:null,f=c.sel,e=b.head||a.getCursor("head"),g=a.listSelections().length;if("eol"==d)e=m(e.line,C(a,e.line));else if("charAfter"==d)e=B(e,0,1);else if("firstNonBlank"==
d)e=S.moveToFirstNonWhiteSpaceCharacter(a,e);else if("startOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.min(f.head.ch,f.anchor.ch)),g=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line<f.anchor.line?f.head:m(f.anchor.line,0);else if("endOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.max(f.head.ch+1,f.anchor.ch)),g=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line>=f.anchor.line?B(f.head,0,1):m(f.anchor.line,0);else if("inplace"==
d&&c.visualMode)return;a.setOption("disableInput",!1);b&&b.replace?(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),h.signal(a,"vim-mode-change",{mode:"replace"})):(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),h.signal(a,"vim-mode-change",{mode:"insert"}));p.macroModeState.isPlaying||(a.on("change",Ta),h.on(a.getInputField(),"keydown",Ua));c.visualMode&&J(a);Ja(a,e,g)}},toggleVisualMode:function(a,b,c){var d=b.repeat,f=a.getCursor();c.visualMode?c.visualLine^b.linewise||c.visualBlock^
b.blockwise?(c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,h.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),W(a)):J(a):(c.visualMode=!0,c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,b=E(a,m(f.line,f.ch+d-1),!0),c.sel={anchor:f,head:b},h.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),W(a),N(a,c,"<",G(f,b)),N(a,c,">",T(f,b)))},reselectLastSelection:function(a,b,c){b=c.lastSelection;
c.visualMode&&Ka(a,c);if(b){var d=b.anchorMark.find(),f=b.headMark.find();d&&f&&(c.sel={anchor:d,head:f},c.visualMode=!0,c.visualLine=b.visualLine,c.visualBlock=b.visualBlock,W(a),N(a,c,"<",G(d,f)),N(a,c,">",T(d,f)),h.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}))}},joinLines:function(a,b,c){var d;if(c.visualMode){b=a.getCursor("anchor");d=a.getCursor("head");if(x(d,b)){var f=d;d=b;b=f}d.ch=C(a,d.line)-1}else d=Math.max(b.repeat,2),b=a.getCursor(),
d=E(a,m(b.line+d-1,Infinity));for(var e=0,g=b.line;g<d.line;g++){var e=C(a,b.line),f=m(b.line+1,C(a,b.line+1)),h=a.getRange(b,f),h=h.replace(/\n\s*/g," ");a.replaceRange(h,b,f)}b=m(b.line,e);c.visualMode&&J(a,!1);a.setCursor(b)},newLineAndEnterInsertMode:function(a,b,c){c.insertMode=!0;var d=y(a.getCursor());d.line!==a.firstLine()||b.after?(d.line=b.after?d.line:d.line-1,d.ch=C(a,d.line),a.setCursor(d),(h.commands.newlineAndIndentContinueComment||h.commands.newlineAndIndent)(a)):(a.replaceRange("\n",
m(a.firstLine(),0)),a.setCursor(a.firstLine(),0));this.enterInsertMode(a,{repeat:b.repeat},c)},paste:function(a,b,c){var d=y(a.getCursor()),f=p.registerController.getRegister(b.registerName),e=f.toString();if(e){if(b.matchIndent)var g=a.getOption("tabSize"),h=function(a){var b=a.split("\t").length-1;a=a.split(" ").length-1;return b*g+1*a},k=a.getLine(a.getCursor().line),r=h(k.match(/^\s*/)[0]),k=e.replace(/\n$/,""),q=e!==k,u=h(e.match(/^\s*/)[0]),e=k.replace(/^\s*/gm,function(b){b=r+(h(b)-u);return 0>
b?"":a.getOption("indentWithTabs")?Array(Math.floor(b/g)+1).join("\t"):Array(b+1).join(" ")}),e=e+(q?"\n":"");1<b.repeat&&(e=Array(b.repeat+1).join(e));k=f.linewise;f=f.blockwise;if(k)c.visualMode?e=c.visualLine?e.slice(0,-1):"\n"+e.slice(0,e.length-1)+"\n":b.after?(e="\n"+e.slice(0,e.length-1),d.ch=C(a,d.line)):d.ch=0;else{if(f)for(e=e.split("\n"),q=0;q<e.length;q++)e[q]=""==e[q]?" ":e[q];d.ch+=b.after?1:0}var n;if(c.visualMode){c.lastPastedText=e;b=ib(a,c);d=b[0];b=b[1];var q=a.getSelection(),t=
a.listSelections(),t=Array(t.length).join("1").split("1");c.lastSelection&&(n=c.lastSelection.headMark.find());p.registerController.unnamedRegister.setText(q);f?(a.replaceSelections(t),b=m(d.line+e.length-1,d.ch),a.setCursor(d),Ia(a,b),a.replaceSelections(e),e=d):c.visualBlock?(a.replaceSelections(t),a.setCursor(d),a.replaceRange(e,d,d),e=d):(a.replaceRange(e,d,b),e=a.posFromIndex(a.indexFromPos(d)+e.length-1));n&&(c.lastSelection.headMark=a.setBookmark(n));k&&(e.ch=0)}else if(f){a.setCursor(d);for(q=
0;q<e.length;q++)n=d.line+q,n>a.lastLine()&&a.replaceRange("\n",m(n,0)),C(a,n)<d.ch&&hb(a,n,d.ch);a.setCursor(d);Ia(a,m(d.line+e.length-1,d.ch));a.replaceSelections(e);e=d}else a.replaceRange(e,d),k&&b.after?e=m(d.line+1,K(a.getLine(d.line+1))):k&&!b.after?e=m(d.line,K(a.getLine(d.line))):!k&&b.after?(n=a.indexFromPos(d),e=a.posFromIndex(n+e.length-1)):(n=a.indexFromPos(d),e=a.posFromIndex(n+e.length));c.visualMode&&J(a,!1);a.setCursor(e)}},undo:function(a,b){a.operation(function(){Ga(a,h.commands.undo,
b.repeat)();a.setCursor(a.getCursor("anchor"))})},redo:function(a,b){Ga(a,h.commands.redo,b.repeat)()},setRegister:function(a,b,c){c.inputState.registerName=b.selectedCharacter},setMark:function(a,b,c){N(a,c,b.selectedCharacter,a.getCursor())},replace:function(a,b,c){var d=b.selectedCharacter,f=a.getCursor(),e,g=a.listSelections();c.visualMode?(f=a.getCursor("start"),e=a.getCursor("end")):(e=a.getLine(f.line),b=f.ch+b.repeat,b>e.length&&(b=e.length),e=m(f.line,b));"\n"==d?(c.visualMode||a.replaceRange("",
f,e),(h.commands.newlineAndIndentContinueComment||h.commands.newlineAndIndent)(a)):(b=a.getRange(f,e),b=b.replace(/[^\n]/g,d),c.visualBlock?(f=Array(a.getOption("tabSize")+1).join(" "),b=a.getSelection(),b=b.replace(/\t/g,f).replace(/[^\n]/g,d).split("\n"),a.replaceSelections(b)):a.replaceRange(b,f,e),c.visualMode?(f=x(g[0].anchor,g[0].head)?g[0].anchor:g[0].head,a.setCursor(f),J(a,!1)):a.setCursor(B(e,0,-1)))},incrementNumberToken:function(a,b){for(var c=a.getCursor(),d=a.getLine(c.line),f=/-?\d+/g,
e,g,h,k;null!==(e=f.exec(d))&&!(k=e[0],g=e.index,h=g+k.length,c.ch<h););!b.backtrack&&h<=c.ch||!k||(d=b.increase?1:-1,k=parseInt(k)+d*b.repeat,b=m(c.line,g),h=m(c.line,h),k=k.toString(),a.replaceRange(k,b,h),a.setCursor(m(c.line,g+k.length-1)))},repeatLastEdit:function(a,b,c){if(c.lastEditInputState){var d=b.repeat;d&&b.repeatIsExplicit?c.lastEditInputState.repeatOverride=d:d=c.lastEditInputState.repeatOverride||d;Va(a,c,d,!1)}},indent:function(a,b){a.indentLine(a.getCursor().line,b.indentRight)},
exitInsertMode:Y},pb={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},bb={bracket:{isComplete:function(a){if(a.nextCh===a.symb){if(a.depth++,1<=a.depth)return!0}else a.nextCh===a.reverseSymb&&a.depth--;return!1}},section:{init:function(a){a.curMoveThrough=!0;a.symb=(a.forward?"]":"[")===a.symb?"{":"}"},isComplete:function(a){return 0===a.index&&a.nextCh===a.symb}},comment:{isComplete:function(a){var b=
"*"===a.lastCh&&"/"===a.nextCh;a.lastCh=a.nextCh;return b}},method:{init:function(a){a.symb="m"===a.symb?"{":"}";a.reverseSymb="{"===a.symb?"}":"{"},isComplete:function(a){return a.nextCh===a.symb?!0:!1}},preprocess:{init:function(a){a.index=0},isComplete:function(a){if("#"===a.nextCh){var b=a.lineText.match(/#(\w+)/)[1];if("endif"===b){if(a.forward&&0===a.depth)return!0;a.depth++}else if("if"===b){if(!a.forward&&0===a.depth)return!0;a.depth--}if("else"===b&&0===a.depth)return!0}return!1}}};da("pcre",
!0,"boolean");Oa.prototype={getQuery:function(){return p.query},setQuery:function(a){p.query=a},getOverlay:function(){return this.searchOverlay},setOverlay:function(a){this.searchOverlay=a},isReversed:function(){return p.isReversed},setReversed:function(a){p.isReversed=a},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(a){this.annotate=a}};var cb={"\\n":"\n","\\r":"\r","\\t":"\t"},db={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"},ob="(Javascript regexp)",
Z=function(){this.buildCommandMap_()};Z.prototype={processCommand:function(a,b,c){var d=this;a.operation(function(){a.curOp.isVimOp=!0;d._processCommand(a,b,c)})},_processCommand:function(a,b,c){var d=a.state.vim,f=p.registerController.getRegister(":"),e=f.toString();d.visualMode&&J(a);d=new h.StringStream(b);f.setText(b);c=c||{};c.input=b;try{this.parseInput_(a,d,c)}catch(k){throw w(a,k),k;}var g,l;if(c.commandName){if(g=this.matchCommand_(c.commandName)){l=g.name;g.excludeFromCommandHistory&&f.setText(e);
this.parseCommandArgs_(d,c,g);if("exToKey"==g.type){for(b=0;b<g.toKeys.length;b++)h.Vim.handleKey(a,g.toKeys[b],"mapping");return}if("exToEx"==g.type){this.processCommand(a,g.toInput);return}}}else void 0!==c.line&&(l="move");if(l)try{$a[l](a,c),g&&g.possiblyAsync||!c.callback||c.callback()}catch(k){throw w(a,k),k;}else w(a,'Not an editor command ":'+b+'"')},parseInput_:function(a,b,c){b.eatWhile(":");b.eat("%")?(c.line=a.firstLine(),c.lineEnd=a.lastLine()):(c.line=this.parseLineSpec_(a,b),void 0!==
c.line&&b.eat(",")&&(c.lineEnd=this.parseLineSpec_(a,b)));a=b.match(/^(\w+)/);c.commandName=a?a[1]:b.match(/.*/)[0];return c},parseLineSpec_:function(a,b){var c=b.match(/^(\d+)/);if(c)return parseInt(c[1],10)-1;switch(b.next()){case ".":return a.getCursor().line;case "$":return a.lastLine();case "'":if((a=a.state.vim.marks[b.next()])&&a.find())return a.find().line;throw Error("Mark not set");default:b.backUp(1)}},parseCommandArgs_:function(a,b,c){a.eol()||(b.argString=a.match(/.*/)[0],a=c.argDelimiter||
/\s+/,a=qa(b.argString).split(a),a.length&&a[0]&&(b.args=a))},matchCommand_:function(a){for(var b=a.length;0<b;b--){var c=a.substring(0,b);if(this.commandMap_[c]&&(c=this.commandMap_[c],0===c.name.indexOf(a)))return c}return null},buildCommandMap_:function(){this.commandMap_={};for(var a=0;a<u.length;a++){var b=u[a];this.commandMap_[b.shortName||b.name]=b}},map:function(a,b,c){if(":"!=a&&":"==a.charAt(0)){if(c)throw Error("Mode not supported for ex mappings");c=a.substring(1);":"!=b&&":"==b.charAt(0)?
this.commandMap_[c]={name:c,type:"exToEx",toInput:b.substring(1),user:!0}:this.commandMap_[c]={name:c,type:"exToKey",toKeys:b,user:!0}}else b=":"!=b&&":"==b.charAt(0)?{keys:a,type:"keyToEx",exArgs:{input:b.substring(1)},user:!0}:{keys:a,type:"keyToKey",toKeys:b,user:!0},c&&(b.context=c),r.unshift(b)},unmap:function(a,b){if(":"!=a&&":"==a.charAt(0)){if(b)throw Error("Mode not supported for ex mappings");a=a.substring(1);if(this.commandMap_[a]&&this.commandMap_[a].user){delete this.commandMap_[a];return}}else for(var c=
0;c<r.length;c++)if(a==r[c].keys&&r[c].context===b&&r[c].user){r.splice(c,1);return}throw Error("No such mapping.");}};var $a={colorscheme:function(a,b){!b.args||1>b.args.length?w(a,a.getOption("theme")):a.setOption("theme",b.args[0])},map:function(a,b,c){var d=b.args;!d||2>d.length?a&&w(a,"Invalid mapping: "+b.input):L.map(d[0],d[1],c)},imap:function(a,b){this.map(a,b,"insert")},nmap:function(a,b){this.map(a,b,"normal")},vmap:function(a,b){this.map(a,b,"visual")},unmap:function(a,b,c){var d=b.args;
!d||1>d.length?a&&w(a,"No such mapping: "+b.input):L.unmap(d[0],c)},move:function(a,b){R.processCommand(a,a.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:b.line+1})},set:function(a,b){var c=b.args,d=b.setCfg||{};if(!c||1>c.length)a&&w(a,"Invalid mapping: "+b.input);else{var f=c[0].split("="),c=f[0],f=f[1],e=!1;if("?"==c.charAt(c.length-1)){if(f)throw Error("Trailing characters: "+b.argString);c=c.substring(0,c.length-
1);e=!0}void 0===f&&"no"==c.substring(0,2)&&(c=c.substring(2),f=!1);(b=M[c]&&"boolean"==M[c].type)&&void 0==f&&(f=!0);!b&&void 0===f||e?(d=V(c,a,d),!0===d||!1===d?w(a," "+(d?"":"no")+c):w(a," "+c+"="+d)):oa(c,f,a,d)}},setlocal:function(a,b){b.setCfg={scope:"local"};this.set(a,b)},setglobal:function(a,b){b.setCfg={scope:"global"};this.set(a,b)},registers:function(a,b){var c=b.args;b=p.registerController.registers;var d="----------Registers----------<br><br>";if(c)for(var c=c.join(""),f=0;f<c.length;f++){if(g=
c.charAt(f),p.registerController.isValidRegister(g))var e=b[g]||new H,d=d+('"'+g+" "+e.toString()+"<br>")}else for(var g in b)c=b[g].toString(),c.length&&(d+='"'+g+" "+c+"<br>");w(a,d)},sort:function(a,b){function c(a,b){if(d){var c;c=a;a=b;b=c}f&&(a=a.toLowerCase(),b=b.toLowerCase());c=g&&q.exec(a);var e=g&&q.exec(b);if(!c)return a<b?-1:1;c=parseInt((c[1]+c[2]).toLowerCase(),r);e=parseInt((e[1]+e[2]).toLowerCase(),r);return c-e}var d,f,e,g,l=function(){if(b.argString){var a=new h.StringStream(b.argString);
a.eat("!")&&(d=!0);if(!a.eol()){if(!a.eatSpace())return"Invalid arguments";var c=a.match(/[a-z]+/);if(c){c=c[0];f=-1!=c.indexOf("i");e=-1!=c.indexOf("u");var k=-1!=c.indexOf("d")&&1,l=-1!=c.indexOf("x")&&1,c=-1!=c.indexOf("o")&&1;if(1<k+l+c)return"Invalid arguments";g=k&&"decimal"||l&&"hex"||c&&"octal"}if(a.match(/\/.*\//))return"patterns not supported"}}}();if(l)w(a,l+": "+b.argString);else{var l=b.line||a.firstLine(),k=b.lineEnd||b.line||a.lastLine();if(l!=k){var l=m(l,0),k=m(k,C(a,k)),p=a.getRange(l,
k).split("\n"),q="decimal"==g?/(-?)([\d]+)/:"hex"==g?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==g?/([0-7]+)/:null,r="decimal"==g?10:"hex"==g?16:"octal"==g?8:null,n=[],t=[];if(g)for(var v=0;v<p.length;v++)q.exec(p[v])?n.push(p[v]):t.push(p[v]);else t=p;n.sort(c);t.sort(c);p=d?n.concat(t):t.concat(n);if(e)for(var n=p,u,p=[],v=0;v<n.length;v++)n[v]!=u&&p.push(n[v]),u=n[v];a.replaceRange(p.join("\n"),l,k)}}},global:function(a,b){var c=b.argString;if(c){var d=void 0!==b.line?b.line:a.firstLine();b=b.lineEnd||
b.line||a.lastLine();var f=Pa(c),e;f.length&&(c=f[0],e=f.slice(1,f.length).join("/"));if(c)try{X(a,c,!0,!0)}catch(z){w(a,"Invalid regex: "+c);return}for(var c=O(a).getQuery(),g=[],f="";d<=b;d++)c.test(a.getLine(d))&&(g.push(d+1),f+=a.getLine(d)+"<br>");if(e){var h=0,k=function(){h<g.length&&L.processCommand(a,g[h]+e,{callback:k});h++};k()}else w(a,f)}else w(a,"Regular Expression missing from global")},substitute:function(a,b){if(!a.getSearchCursor)throw Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");
var c=b.argString,d=c?Pa(c):[],f,e="",g,l,k=!1,r=!1;if(d.length){f=d[0];e=d[1];if(void 0!==e){if(V("pcre"))for(e=new h.StringStream(e),g=[];!e.eol();){for(;e.peek()&&"\\"!=e.peek();)g.push(e.next());var c=!1,q;for(q in db)if(e.match(q,!0)){c=!0;g.push(db[q]);break}c||g.push(e.next())}else for(q=!1,g=[],c=-1;c<e.length;c++){var u=e.charAt(c)||"",n=e.charAt(c+1)||"";cb[u+n]?(g.push(cb[u+n]),c++):q?(g.push(u),q=!1):"\\"===u?(q=!0,nb.test(n)||"$"===n?g.push("$"):"/"!==n&&"\\"!==n&&g.push("\\")):("$"===
u&&g.push("$"),g.push(u),"/"===n&&g.push("\\"))}e=g.join("");p.lastSubstituteReplacePart=e}g=d[2]?d[2].split(" "):[]}else if(c&&c.length){w(a,"Substitutions should be of the form :s/pattern/replace/");return}g&&(d=g[0],l=parseInt(g[1]),d&&(-1!=d.indexOf("c")&&(k=!0,d.replace("c","")),-1!=d.indexOf("g")&&(r=!0,d.replace("g","")),f=f+"/"+d));if(f)try{X(a,f,!0,!0)}catch(t){w(a,"Invalid regex: "+f);return}e=e||p.lastSubstituteReplacePart;void 0===e?w(a,"No previous substitute regular expression"):(f=
O(a).getQuery(),d=void 0!==b.line?b.line:a.getCursor().line,q=b.lineEnd||d,d==a.firstLine()&&q==a.lastLine()&&(q=Infinity),l&&(d=q,q=d+l-1),l=E(a,m(d,0)),l=a.getSearchCursor(f,l),mb(a,k,r,d,q,l,f,e,b.callback))},redo:h.commands.redo,undo:h.commands.undo,write:function(a){h.commands.save?h.commands.save(a):a.save&&a.save()},nohlsearch:function(a){ua(a)},yank:function(a){var b=y(a.getCursor()).line;a=a.getLine(b);p.registerController.pushText("0","yank",a,!0,!0)},delmarks:function(a,b){if(b.argString&&
qa(b.argString))for(var c=a.state.vim,d=new h.StringStream(qa(b.argString));!d.eol();){d.eatSpace();var f=d.pos;if(!d.match(/[a-zA-Z]/,!1)){w(a,"Invalid argument: "+b.argString.substring(f));break}var e=d.next();if(d.match("-",!0)){if(!d.match(/[a-zA-Z]/,!1)){w(a,"Invalid argument: "+b.argString.substring(f));break}var g=d.next();if(/^[a-z]$/.test(e)&&/^[a-z]$/.test(g)||U(e)&&U(g)){e=e.charCodeAt(0);g=g.charCodeAt(0);if(e>=g){w(a,"Invalid argument: "+b.argString.substring(f));break}for(f=0;f<=g-e;f++){var l=
String.fromCharCode(e+f);delete c.marks[l]}}else{w(a,"Invalid argument: "+e+"-");break}}else delete c.marks[e]}else w(a,"Argument required")}},L=new Z;h.keyMap.vim={attach:P,detach:A,call:la};da("insertModeEscKeysTimeout",200,"number");h.keyMap["vim-insert"]={fallthrough:["default"],attach:P,detach:A,call:la};h.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:P,detach:A,call:la};Da();return ka}()});