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