text: !function(e){"object"==typeof exports&&"object"==typeof module?e(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"],e):e(CodeMirror)}(function(e){"use strict";var t=[{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:"xi",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"dcc",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:"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:"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:"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"}],r=[{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:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],n=e.Pos,o=function(){function o(t){t.setOption("disableInput",!0),t.setOption("showCursorWhenSelecting",!1),e.signal(t,"vim-mode-change",{mode:"normal"}),t.on("cursorActivity",et),x(t),e.on(t.getInputField(),"paste",u(t))}function i(t){t.setOption("disableInput",!1),t.off("cursorActivity",et),e.off(t.getInputField(),"paste",u(t)),t.state.vim=null}function a(t,r){this==e.keyMap.vim&&e.rmClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==s||i(t,!1)}function s(t,r){this==e.keyMap.vim&&e.addClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==s||o(t)}function l(t,r){if(r){var n=c(t);if(!n)return!1;var o=e.Vim.findKey(r,n);return"function"==typeof o&&e.signal(r,"vim-keypress",n),o}}function c(e){if("'"==e.charAt(0))return e.charAt(1);var t=e.split(/-(?!$)/),r=t[t.length-1];if(1==t.length&&1==t[0].length)return!1;if(2==t.length&&"Shift"==t[0]&&1==r.length)return!1;for(var n=!1,o=0;o<t.length;o++){var i=t[o];i in st?t[o]=st[i]:n=!0,i in lt&&(t[o]=lt[i])}return n?(g(r)&&(t[t.length-1]=r.toLowerCase()),"<"+t.join("-")+">"):!1}function u(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(j(e.getCursor(),0,1)),bt.enterInsertMode(e,{},t))}),t.onPasteFn}function h(e,t){for(var r=[],n=e;e+t>n;n++)r.push(String.fromCharCode(n));return r}function p(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function f(e){return/^[a-z]$/.test(e)}function d(e){return-1!="()[]{}".indexOf(e)}function m(e){return ct.test(e)}function g(e){return/^[A-Z]$/.test(e)}function v(e){return/^\s*$/.test(e)}function y(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}function k(e,t,r,n,o){if(void 0===t&&!o)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),vt[e]={type:r,defaultValue:t,callback:o},n)for(var i=0;i<n.length;i++)vt[n[i]]=vt[e];t&&C(e,t)}function C(e,t,r,n){var o=vt[e];n=n||{};var i=n.scope;if(!o)throw Error("Unknown option: "+e);if("boolean"==o.type){if(t&&t!==!0)throw Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?("local"!==i&&o.callback(t,void 0),"global"!==i&&r&&o.callback(t,r)):("local"!==i&&(o.value="boolean"==o.type?!!t:t),"global"!==i&&r&&(r.state.vim.options[e]={value:t}))}function w(e,t,r){var n=vt[e];r=r||{};var o=r.scope;if(!n)throw Error("Unknown option: "+e);{if(!n.callback){var i="global"!==o&&t&&t.state.vim.options[e];return(i||"local"!==o&&n||{}).value}var i=t&&n.callback(void 0,t);if("global"!==o&&void 0!==i)return i;if("local"!==o)return n.callback()}}function M(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=kt()}function x(e){return e.state.vim||(e.state.vim={inputState:new A,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:{}}),e.state.vim}function S(){Ct={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:yt(),macroModeState:new M,lastChararacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new R({}),searchHistoryController:new E({}),exCommandHistoryController:new E({})};for(var e in vt){var t=vt[e];t.value=t.defaultValue}}function A(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function b(t,r){t.state.vim.inputState=new A,e.signal(t,"vim-command-done",r)}function L(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function T(e,t){var r=Ct.registerController.registers[e];if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,gt.push(e)}function R(e){this.registers=e,this.unnamedRegister=e['"']=new L,e["."]=new L,e[":"]=new L,e["/"]=new L}function E(){this.historyBuffer=[],this.iterator,this.initialPrefix=null}function B(e,t){St[e]=t}function I(e,t){for(var r=[],n=0;t>n;n++)r.push(e);return r}function O(e,t){At[e]=t}function K(e,t){bt[e]=t}function N(e,t,r){var o=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),i=z(e,o)-1;i=r?i+1:i;var a=Math.min(Math.max(0,t.ch),i);return n(o,a)}function P(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function j(e,t,r){return"object"==typeof t&&(r=t.ch,t=t.line),n(e.line+t,e.ch+r)}function H(e,t){return{line:t.line-e.line,ch:t.line-e.line}}function W(e,t,r,n){for(var o,i=[],a=[],s=0;s<t.length;s++){var l=t[s];"insert"==r&&"insert"!=l.context||l.context&&l.context!=r||n.operator&&"action"==l.type||!(o=F(e,l.keys))||("partial"==o&&i.push(l),"full"==o&&a.push(l))}return{partial:i.length&&i,full:a.length&&a}}function F(e,t){if("<character>"==t.slice(-11)){var r=t.length-11,n=e.slice(0,r),o=t.slice(0,r);return n==o&&e.length>r?"full":0==o.indexOf(n)?"partial":!1}return e==t?"full":0==t.indexOf(e)?"partial":!1}function _(e){var t=/^.*(<[\w\-]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"<CR>":r="\n";break;case"<Space>":r=" "}return r}function D(e,t,r){return function(){for(var n=0;r>n;n++)t(e)}}function V(e){return n(e.line,e.ch)}function U(e,t){return e.ch==t.ch&&e.line==t.line}function J(e,t){return e.line<t.line?!0:e.line==t.line&&e.ch<t.ch?!0:!1}function $(e,t){return arguments.length>2&&(t=$.apply(void 0,Array.prototype.slice.call(arguments,1))),J(e,t)?e:t}function q(e,t){return arguments.length>2&&(t=q.apply(void 0,Array.prototype.slice.call(arguments,1))),J(e,t)?t:e}function Q(e,t,r){var n=J(e,t),o=J(t,r);return n&&o}function z(e,t){return e.getLine(t).length}function Z(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function G(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function X(e,t,r){var o=z(e,t),i=new Array(r-o+1).join(" ");e.setCursor(n(t,o)),e.replaceRange(i,e.getCursor())}function Y(e,t){var r=[],o=e.listSelections(),i=V(e.clipPos(t)),a=!U(t,i),s=e.getCursor("head"),l=te(o,s),c=U(o[l].head,o[l].anchor),u=o.length-1,h=u-l>l?u:0,p=o[h].anchor,f=Math.min(p.line,i.line),d=Math.max(p.line,i.line),m=p.ch,g=i.ch,v=o[h].head.ch-m,y=g-m;v>0&&0>=y?(m++,a||g--):0>v&&y>=0?(m--,c||g++):0>v&&-1==y&&(m--,g++);for(var k=f;d>=k;k++){var C={anchor:new n(k,m),head:new n(k,g)};r.push(C)}return l=i.line==d?r.length-1:0,e.setSelections(r),t.ch=g,p.ch=m,p}function ee(e,t,r){for(var n=[],o=0;r>o;o++){var i=j(t,o,0);n.push({anchor:i,head:i})}e.setSelections(n,0)}function te(e,t,r){for(var n=0;n<e.length;n++){var o="head"!=r&&U(e[n].anchor,t),i="anchor"!=r&&U(e[n].head,t);if(o||i)return n}return-1}function re(e,t){var r=t.lastSelection,o=function(){var t=e.listSelections(),r=t[0],n=t[t.length-1],o=J(r.anchor,r.head)?r.anchor:r.head,i=J(n.anchor,n.head)?n.head:n.anchor;return[o,i]},i=function(){var t=e.getCursor(),o=e.getCursor(),i=r.visualBlock;if(i){var a=i.width,s=i.height;o=n(t.line+s,t.ch+a);for(var l=[],c=t.line;c<o.line;c++){var u=n(c,t.ch),h=n(c,o.ch),p={anchor:u,head:h};l.push(p)}e.setSelections(l)}else{var f=r.anchorMark.find(),d=r.headMark.find(),m=d.line-f.line,g=d.ch-f.ch;o={line:o.line+m,ch:m?o.ch:g+o.ch},r.visualLine&&(t=n(t.line,0),o=n(o.line,z(e,o.line))),e.setSelection(t,o)}return[t,o]};return t.visualMode?o():i()}function ne(e,t){var r=t.sel.anchor,n=t.sel.head;t.lastPastedText&&(n=e.posFromIndex(e.indexFromPos(r)+t.lastPastedText.length),t.lastPastedText=null),t.lastSelection={anchorMark:e.setBookmark(r),headMark:e.setBookmark(n),anchor:V(r),head:V(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function oe(e,t,r){var o,i=e.state.vim.sel,a=i.head,s=i.anchor;return J(r,t)&&(o=r,r=t,t=o),J(a,s)?(a=$(t,a),s=q(s,r)):(s=$(t,s),a=q(a,r),a=j(a,0,-1),-1==a.ch&&a.line!=e.firstLine()&&(a=n(a.line-1,z(e,a.line-1)))),[s,a]}function ie(e,t,r){var n=e.state.vim;t=t||n.sel;var r=r||n.visualLine?"line":n.visualBlock?"block":"char",o=ae(e,t,r);e.setSelections(o.ranges,o.primary),tt(e)}function ae(e,t,r,o){var i=V(t.head),a=V(t.anchor);if("char"==r){var s=o||J(t.head,t.anchor)?0:1,l=J(t.head,t.anchor)?1:0;return i=j(t.head,0,s),a=j(t.anchor,0,l),{ranges:[{anchor:a,head:i}],primary:0}}if("line"==r){if(J(t.head,t.anchor))i.ch=0,a.ch=z(e,a.line);else{a.ch=0;var c=e.lastLine();i.line>c&&(i.line=c),i.ch=z(e,i.line)}return{ranges:[{anchor:a,head:i}],primary:0}}if("block"==r){for(var u=Math.min(a.line,i.line),h=Math.min(a.ch,i.ch),p=Math.max(a.line,i.line),f=Math.max(a.ch,i.ch)+1,d=p-u+1,m=i.line==u?0:d-1,g=[],v=0;d>v;v++)g.push({anchor:n(u+v,h),head:n(u+v,f)});return{ranges:g,primary:m}}}function se(e){var t=e.getCursor("head");return 1==e.getSelection().length&&(t=$(t,e.getCursor("anchor"))),t}function le(t,r){var n=t.state.vim;r!==!1&&t.setCursor(N(t,n.sel.head)),ne(t,n),n.visualMode=!1,n.visualLine=!1,n.visualBlock=!1,e.signal(t,"vim-mode-change",{mode:"normal"}),n.fakeCursor&&n.fakeCursor.clear()}function ce(e,t,r){var n=e.getRange(t,r);if(/\n\s*$/.test(n)){var o=n.split("\n");o.pop();for(var i,i=o.pop();o.length>0&&i&&v(i);i=o.pop())r.line--,r.ch=0;i?(r.line--,r.ch=z(e,r.line)):r.ch=0}}function ue(e,t,r){t.ch=0,r.ch=0,r.line++}function he(e){if(!e)return 0;var t=e.search(/\S/);return-1==t?e.length:t}function pe(e,t,r,o,i){for(var a=se(e),s=e.getLine(a.line),l=a.ch,c=i?ut[0]:ht[0];!c(s.charAt(l));)if(l++,l>=s.length)return null;o?c=ht[0]:(c=ut[0],c(s.charAt(l))||(c=ut[1]));for(var u=l,h=l;c(s.charAt(u))&&u<s.length;)u++;for(;c(s.charAt(h))&&h>=0;)h--;if(h++,t){for(var p=u;/\s/.test(s.charAt(u))&&u<s.length;)u++;if(p==u){for(var f=h;/\s/.test(s.charAt(h-1))&&h>0;)h--;h||(h=f)}}return{start:n(a.line,h),end:n(a.line,u)}}function fe(e,t,r){U(t,r)||Ct.jumpList.add(e,t,r)}function de(e,t){Ct.lastChararacterSearch.increment=e,Ct.lastChararacterSearch.forward=t.forward,Ct.lastChararacterSearch.selectedCharacter=t.selectedCharacter}function me(e,t,r,o){var i=V(e.getCursor()),a=r?1:-1,s=r?e.lineCount():-1,l=i.ch,c=i.line,u=e.getLine(c),h={lineText:u,nextCh:u.charAt(l),lastCh:null,index:l,symb:o,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[o],forward:r,depth:0,curMoveThrough:!1},p=Lt[o];if(!p)return i;var f=Tt[p].init,d=Tt[p].isComplete;for(f&&f(h);c!==s&&t;){if(h.index+=a,h.nextCh=h.lineText.charAt(h.index),!h.nextCh){if(c+=a,h.lineText=e.getLine(c)||"",a>0)h.index=0;else{var m=h.lineText.length;h.index=m>0?m-1:0}h.nextCh=h.lineText.charAt(h.index)}d(h)&&(i.line=c,i.ch=h.index,t--)}return h.nextCh||h.curMoveThrough?n(c,h.index):i}function ge(e,t,r,n,o){var i=t.line,a=t.ch,s=e.getLine(i),l=r?1:-1,c=n?ht:ut;if(o&&""==s){if(i+=l,s=e.getLine(i),!p(e,i))return null;a=r?0:s.length}for(;;){if(o&&""==s)return{from:0,to:0,line:i};for(var u=l>0?s.length:-1,h=u,f=u;a!=u;){for(var d=!1,m=0;m<c.length&&!d;++m)if(c[m](s.charAt(a))){for(h=a;a!=u&&c[m](s.charAt(a));)a+=l;if(f=a,d=h!=f,h==t.ch&&i==t.line&&f==h+l)continue;return{from:Math.min(h,f+1),to:Math.max(h,f),line:i}}d||(a+=l)}if(i+=l,!p(e,i))return null;s=e.getLine(i),a=l>0?0:s.length}throw new Error("The impossible happened.")}function ve(e,t,r,o,i,a){var s=V(t),l=[];(o&&!i||!o&&i)&&r++;for(var c=!(o&&i),u=0;r>u;u++){var h=ge(e,t,o,a,c);if(!h){var p=z(e,e.lastLine());l.push(o?{line:e.lastLine(),from:p,to:p}:{line:0,from:0,to:0});break}l.push(h),t=n(h.line,o?h.to-1:h.from)}var f=l.length!=r,d=l[0],m=l.pop();return o&&!i?(f||d.from==s.ch&&d.line==s.line||(m=l.pop()),n(m.line,m.from)):o&&i?n(m.line,m.to-1):!o&&i?(f||d.to==s.ch&&d.line==s.line||(m=l.pop()),n(m.line,m.to)):n(m.line,m.from)}function ye(e,t,r,o){for(var i,a=e.getCursor(),s=a.ch,l=0;t>l;l++){var c=e.getLine(a.line);if(i=we(s,c,o,r,!0),-1==i)return null;s=i}return n(e.getCursor().line,i)}function ke(e,t){var r=e.getCursor().line;return N(e,n(r,t-1))}function Ce(e,t,r,n){y(r,mt)&&(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function we(e,t,r,n,o){var i;return n?(i=t.indexOf(r,e+1),-1==i||o||(i-=1)):(i=t.lastIndexOf(r,e-1),-1==i||o||(i+=1)),i}function Me(e,t,r,o,i){function a(t){return!e.getLine(t)}function s(e,t,r){return r?a(e)!=a(e+t):!a(e)&&a(e+t)}var l,c,u=t.line,h=e.firstLine(),p=e.lastLine(),f=u;if(o){for(;f>=h&&p>=f&&r>0;)s(f,o)&&r--,f+=o;return new n(f,0)}var d=e.state.vim;if(d.visualLine&&s(u,1,!0)){var m=d.sel.anchor;s(m.line,-1,!0)&&(i&&m.line==u||(u+=1))}var g=a(u);for(f=u;p>=f&&r;f++)s(f,1,!0)&&(i&&a(f)==g||r--);for(c=new n(f,0),f>p&&!g?g=!0:i=!1,f=u;f>h&&(i&&a(f)!=g&&f!=u||!s(f,-1,!0));f--);return l=new n(f,0),{start:l,end:c}}function xe(e,t,r,o){var i,a,s=t,l={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[r],c={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[r],u=e.getLine(s.line).charAt(s.ch),h=u===c?1:0;if(i=e.scanForBracket(n(s.line,s.ch+h),-1,null,{bracketRegex:l}),a=e.scanForBracket(n(s.line,s.ch+h),1,null,{bracketRegex:l}),!i||!a)return{start:s,end:s};if(i=i.pos,a=a.pos,i.line==a.line&&i.ch>a.ch||i.line>a.line){var p=i;i=a,a=p}return o?a.ch+=1:i.ch+=1,{start:i,end:a}}function Se(e,t,r,o){var i,a,s,l,c=V(t),u=e.getLine(c.line),h=u.split(""),p=h.indexOf(r);if(c.ch<p?c.ch=p:p<c.ch&&h[c.ch]==r&&(a=c.ch,--c.ch),h[c.ch]!=r||a)for(s=c.ch;s>-1&&!i;s--)h[s]==r&&(i=s+1);else i=c.ch+1;if(i&&!a)for(s=i,l=h.length;l>s&&!a;s++)h[s]==r&&(a=s);return i&&a?(o&&(--i,++a),{start:n(c.line,i),end:n(c.line,a)}):{start:c,end:c}}function Ae(){}function be(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new Ae)}function Le(e,t,r,n,o){e.openDialog?e.openDialog(t,n,{bottom:!0,value:o.value,onKeyDown:o.onKeyDown,onKeyUp:o.onKeyUp,selectValueOnOpen:!1}):n(prompt(r,""))}function Te(e){var t=Re(e)||[];if(!t.length)return[];var r=[];if(0===t[0]){for(var n=0;n<t.length;n++)"number"==typeof t[n]&&r.push(e.substring(t[n]+1,t[n+1]));return r}}function Re(e){for(var t=!1,r=[],n=0;n<e.length;n++){var o=e.charAt(n);t||"/"!=o||r.push(n),t=!t&&"\\"==o}return r}function Ee(e){for(var t="|(){",r="}",n=!1,o=[],i=-1;i<e.length;i++){var a=e.charAt(i)||"",s=e.charAt(i+1)||"",l=s&&-1!=t.indexOf(s);n?("\\"===a&&l||o.push(a),n=!1):"\\"===a?(n=!0,s&&-1!=r.indexOf(s)&&(l=!0),l&&"\\"!==s||o.push(a)):(o.push(a),l&&"\\"!==s&&o.push("\\"))}return o.join("")}function Be(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var o=e.charAt(n)||"",i=e.charAt(n+1)||"";Rt[o+i]?(r.push(Rt[o+i]),n++):t?(r.push(o),t=!1):"\\"===o?(t=!0,m(i)||"$"===i?r.push("$"):"/"!==i&&"\\"!==i&&r.push("\\")):("$"===o&&r.push("$"),r.push(o),"/"===i&&r.push("\\"))}return r.join("")}function Ie(t){for(var r=new e.StringStream(t),n=[];!r.eol();){for(;r.peek()&&"\\"!=r.peek();)n.push(r.next());var o=!1;for(var i in Et)if(r.match(i,!0)){o=!0,n.push(Et[i]);break}o||n.push(r.next())}return n.join("")}function Oe(e,t,r){var n=Ct.registerController.getRegister("/");if(n.setText(e),e instanceof RegExp)return e;var o,i,a=Re(e);if(a.length){o=e.substring(0,a[0]);var s=e.substring(a[0]);i=-1!=s.indexOf("i")}else o=e;if(!o)return null;w("pcre")||(o=Ee(o)),r&&(t=/^[^A-Z]*$/.test(o));var l=new RegExp(o,t||i?"i":void 0);return l}function Ke(e,t){e.openNotification?e.openNotification('<span style="color: red">'+t+"</span>",{bottom:!0,duration:5e3}):alert(t)}function Ne(e,t){var r="";return e&&(r+='<span style="font-family: monospace">'+e+"</span>"),r+='<input type="text"/> <span style="color: #888">',t&&(r+='<span style="color: #888">',r+=t,r+="</span>"),r}function Pe(e,t){var r=(t.prefix||"")+" "+(t.desc||""),n=Ne(t.prefix,t.desc);Le(e,n,r,t.onClose,t)}function je(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n<r.length;n++){var o=r[n];if(e[o]!==t[o])return!1}return!0}return!1}function He(e,t,r,n){if(t){var o=be(e),i=Oe(t,!!r,!!n);if(i)return Fe(e,i),je(i,o.getQuery())?i:(o.setQuery(i),i)}}function We(e){if("^"==e.source.charAt(0))var t=!0;return{token:function(r){if(t&&!r.sol())return void r.skipToEnd();var n=r.match(e,!1);if(n)return 0==n[0].length?(r.next(),"searching"):r.sol()||(r.backUp(1),e.exec(r.next()+n[0]))?(r.match(e),"searching"):(r.next(),null);for(;!r.eol()&&(r.next(),!r.match(e,!1)););},query:e}}function Fe(e,t){var r=be(e),n=r.getOverlay();n&&t==n.query||(n&&e.removeOverlay(n),n=We(t),e.addOverlay(n),e.showMatchesOnScrollbar&&(r.getScrollbarAnnotate()&&r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),r.setOverlay(n))}function _e(e,t,r,o){return void 0===o&&(o=1),e.operation(function(){for(var i=e.getCursor(),a=e.getSearchCursor(r,i),s=0;o>s;s++){var l=a.find(t);if(0==s&&l&&U(a.from(),i)&&(l=a.find(t)),!l&&(a=e.getSearchCursor(r,t?n(e.lastLine()):n(e.firstLine(),0)),!a.find(t)))return}return a.from()})}function De(e){var t=be(e);e.removeOverlay(be(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Ve(e,t,r){return"number"!=typeof e&&(e=e.line),t instanceof Array?y(e,t):r?e>=t&&r>=e:e==t}function Ue(e){var t=e.getScrollInfo(),r=6,n=10,o=e.coordsChar({left:0,top:r+t.top},"local"),i=t.clientHeight-n+t.top,a=e.coordsChar({left:0,top:i},"local");return{top:o.line,bottom:a.line}}function Je(t,r,n,o,i,a,s,l,c){function u(){t.operation(function(){for(;!m;)h(),p();f()})}function h(){var e=t.getRange(a.from(),a.to()),r=e.replace(s,l);a.replace(r)}function p(){for(;a.findNext()&&Ve(a.from(),o,i);)if(n||!g||a.from().line!=g.line)return t.scrollIntoView(a.from(),30),t.setSelection(a.from(),a.to()),g=a.from(),void(m=!1);m=!0}function f(e){if(e&&e(),t.focus(),g){t.setCursor(g);var r=t.state.vim;r.exMode=!1,r.lastHPos=r.lastHSPos=g.ch}c&&c()}function d(r,n,o){e.e_stop(r);var i=e.keyName(r);switch(i){case"Y":h(),p();break;case"N":p();break;case"A":var a=c;c=void 0,t.operation(u),c=a;break;case"L":h();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":f(o)}return m&&f(o),!0}t.state.vim.exMode=!0;var m=!1,g=a.from();return p(),m?void Ke(t,"No matches for "+s.source):r?void Pe(t,{prefix:"replace with <strong>"+l+"</strong> (y/n/a/q/l)",onKeyDown:d}):(u(),void(c&&c()))}function $e(t){var r=t.state.vim,n=Ct.macroModeState,o=Ct.registerController.getRegister("."),i=n.isPlaying,a=n.lastInsertModeChanges,s=[];if(!i){for(var l=a.inVisualBlock?r.lastSelection.visualBlock.height:1,c=a.changes,s=[],u=0;u<c.length;)s.push(c[u]),c[u]instanceof nt?u++:u+=l;a.changes=s,t.off("change",Ye),e.off(t.getInputField(),"keydown",ot)}!i&&r.insertModeRepeat>1&&(it(t,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t.setCursor(t.getCursor().line,t.getCursor().ch-1),t.setOption("keyMap","vim"),t.setOption("disableInput",!0),t.toggleOverwrite(!1),o.setText(a.changes.join("")),e.signal(t,"vim-mode-change",{mode:"normal"}),n.isRecording&&Ge(n)}function qe(e){t.unshift(e)}function Qe(e,t,r,n,o){var i={keys:e,type:t};i[t]=r,i[t+"Args"]=n;for(var a in o)i[a]=o[a];qe(i)}function ze(t,r,n,o){var i=Ct.registerController.getRegister(o);if(":"==o)return i.keyBuffer[0]&&Kt.processCommand(t,i.keyBuffer[0]),void(n.isPlaying=!1);var a=i.keyBuffer,s=0;n.isPlaying=!0,n.replaySearchQueries=i.searchQueries.slice(0);for(var l=0;l<a.length;l++)for(var c,u,h=a[l];h;)if(c=/<\w+-.+?>|<\w+>|./.exec(h),u=c[0],h=h.substring(c.index+u.length),e.Vim.handleKey(t,u,"macro"),r.insertMode){var p=i.insertModeChanges[s++].changes;Ct.macroModeState.lastInsertModeChanges.changes=p,at(t,p,1),$e(t);
  }n.isPlaying=!1}function Ze(e,t){if(!e.isPlaying){var r=e.latestRegister,n=Ct.registerController.getRegister(r);n&&n.pushText(t)}}function Ge(e){if(!e.isPlaying){var t=e.latestRegister,r=Ct.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function Xe(e,t){if(!e.isPlaying){var r=e.latestRegister,n=Ct.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function Ye(e,t){var r=Ct.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(;t;){if(n.expectCursorActivityForChange=!0,"+input"==t.origin||"paste"==t.origin||void 0===t.origin){var o=t.text.join("\n");n.changes.push(o)}t=t.next}}function et(e){var t=e.state.vim;if(t.insertMode){var r=Ct.macroModeState;if(r.isPlaying)return;var n=r.lastInsertModeChanges;n.expectCursorActivityForChange?n.expectCursorActivityForChange=!1:n.changes=[]}else e.curOp.isVimOp||rt(e,t);t.visualMode&&tt(e)}function tt(e){var t=e.state.vim,r=N(e,V(t.sel.head)),n=j(r,0,1);t.fakeCursor&&t.fakeCursor.clear(),t.fakeCursor=e.markText(r,n,{className:"cm-animate-fat-cursor"})}function rt(t,r){var n=t.getCursor("anchor"),o=t.getCursor("head");if(r.visualMode&&!t.somethingSelected()?le(t,!1):r.visualMode||r.insertMode||!t.somethingSelected()||(r.visualMode=!0,r.visualLine=!1,e.signal(t,"vim-mode-change",{mode:"visual"})),r.visualMode){var i=J(o,n)?0:-1,a=J(o,n)?-1:0;o=j(o,0,i),n=j(n,0,a),r.sel={anchor:n,head:o},Ce(t,r,"<",$(o,n)),Ce(t,r,">",q(o,n))}else r.insertMode||(r.lastHPos=t.getCursor().ch)}function nt(e){this.keyName=e}function ot(t){function r(){return o.changes.push(new nt(i)),!0}var n=Ct.macroModeState,o=n.lastInsertModeChanges,i=e.keyName(t);i&&(-1!=i.indexOf("Delete")||-1!=i.indexOf("Backspace"))&&e.lookupKey(i,"vim-insert",r)}function it(e,t,r,n){function o(){s?xt.processAction(e,t,t.lastEditActionCommand):xt.evalInput(e,t)}function i(r){if(a.lastInsertModeChanges.changes.length>0){r=t.lastEditActionCommand?r:1;var n=a.lastInsertModeChanges;at(e,n.changes,r)}}var a=Ct.macroModeState;a.isPlaying=!0;var s=!!t.lastEditActionCommand,l=t.inputState;if(t.inputState=t.lastEditInputState,s&&t.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;r>c;c++)o(),i(1);else n||o(),i(r);t.inputState=l,t.insertMode&&!n&&$e(e),a.isPlaying=!1}function at(t,r,n){function o(r){return"string"==typeof r?e.commands[r](t):r(t),!0}var i=t.getCursor("head"),a=Ct.macroModeState.lastInsertModeChanges.inVisualBlock;if(a){var s=t.state.vim,l=s.lastSelection,c=H(l.anchor,l.head);ee(t,i,c.line+1),n=t.listSelections().length,t.setCursor(i)}for(var u=0;n>u;u++){a&&t.setCursor(j(i,u,0));for(var h=0;h<r.length;h++){var p=r[h];if(p instanceof nt)e.lookupKey(p.keyName,"vim-insert",o);else{var f=t.getCursor();t.replaceRange(p,f,f)}}}a&&t.setCursor(j(i,0,1))}e.defineOption("vimMode",!1,function(t,r,n){r&&"vim"!=t.getOption("keyMap")?t.setOption("keyMap","vim"):!r&&n!=e.Init&&/^vim/.test(t.getOption("keyMap"))&&t.setOption("keyMap","default")});var st={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},lt={Enter:"CR",Backspace:"BS",Delete:"Del"},ct=/[\d]/,ut=[e.isWordChar,function(t){return t&&!e.isWordChar(t)&&!/\s/.test(t)}],ht=[function(e){return/\S/.test(e)}],pt=h(65,26),ft=h(97,26),dt=h(48,10),mt=[].concat(pt,ft,dt,["<",">"]),gt=[].concat(pt,ft,dt,["-",'"',".",":","/"]),vt={};k("filetype",void 0,"string",["ft"],function(e,t){if(void 0!==t){if(void 0===e){var r=t.getOption("mode");return"null"==r?"":r}var r=""==e?"null":e;t.setOption("mode",r)}});var yt=function(){function e(e,t,s){function l(t){var o=++n%r,i=a[o];i&&i.clear(),a[o]=e.setBookmark(t)}var c=n%r,u=a[c];if(u){var h=u.find();h&&!U(h,t)&&l(t)}else l(t);l(s),o=n,i=n-r+1,0>i&&(i=0)}function t(e,t){n+=t,n>o?n=o:i>n&&(n=i);var s=a[(r+n)%r];if(s&&!s.find()){var l,c=t>0?1:-1,u=e.getCursor();do if(n+=c,s=a[(r+n)%r],s&&(l=s.find())&&!U(u,l))break;while(o>n&&n>i)}return s}var r=100,n=-1,o=0,i=0,a=new Array(r);return{cachedCursor:void 0,add:e,move:t}},kt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};M.prototype={exitMacroRecordMode:function(){var e=Ct.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var r=Ct.registerController.getRegister(t);r&&(r.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog("(recording)["+t+"]",null,{bottom:!0})),this.isRecording=!0)}};var Ct,wt,Mt={buildKeyMap:function(){},getRegisterController:function(){return Ct.registerController},resetVimGlobalState_:S,getVimGlobalState_:function(){return Ct},maybeInitVimState_:x,suppressErrorLogging:!1,InsertModeKey:nt,map:function(e,t,r){Kt.map(e,t,r)},setOption:C,getOption:w,defineOption:k,defineEx:function(e,t,r){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;Ot[e]=r,Kt.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);return"function"==typeof n?n():void 0},findKey:function(r,n,o){function i(){var e=Ct.macroModeState;if(e.isRecording){if("q"==n)return e.exitMacroRecordMode(),b(r),!0;"mapping"!=o&&Ze(e,n)}}function a(){return"<Esc>"==n?(b(r),h.visualMode?le(r):h.insertMode&&$e(r),!0):void 0}function s(t){for(var o;t;)o=/<\w+-.+?>|<\w+>|./.exec(t),n=o[0],t=t.substring(o.index+n.length),e.Vim.handleKey(r,n,"mapping")}function l(){if(a())return!0;for(var e=h.inputState.keyBuffer=h.inputState.keyBuffer+n,o=1==n.length,i=xt.matchCommand(e,t,h.inputState,"insert");e.length>1&&"full"!=i.type;){var e=h.inputState.keyBuffer=e.slice(1),s=xt.matchCommand(e,t,h.inputState,"insert");"none"!=s.type&&(i=s)}if("none"==i.type)return b(r),!1;if("partial"==i.type)return wt&&window.clearTimeout(wt),wt=window.setTimeout(function(){h.insertMode&&h.inputState.keyBuffer&&b(r)},w("insertModeEscKeysTimeout")),!o;if(wt&&window.clearTimeout(wt),o){var l=r.getCursor();r.replaceRange("",j(l,0,-(e.length-1)),l,"+input")}return b(r),i.command}function c(){if(i()||a())return!0;var e=h.inputState.keyBuffer=h.inputState.keyBuffer+n;if(/^[1-9]\d*$/.test(e))return!0;var o=/^(\d*)(.*)$/.exec(e);if(!o)return b(r),!1;var s=h.visualMode?"visual":"normal",l=xt.matchCommand(o[2]||o[1],t,h.inputState,s);if("none"==l.type)return b(r),!1;if("partial"==l.type)return!0;h.inputState.keyBuffer="";var o=/^(\d*)(.*)$/.exec(e);return o[1]&&"0"!=o[1]&&h.inputState.pushRepeatDigit(o[1]),l.command}var u,h=x(r);return u=h.insertMode?l():c(),u===!1?void 0:u===!0?function(){}:function(){return r.operation(function(){r.curOp.isVimOp=!0;try{"keyToKey"==u.type?s(u.toKeys):xt.processCommand(r,h,u)}catch(t){throw r.state.vim=void 0,x(r),e.Vim.suppressErrorLogging||console.log(t),t}return!0})}},handleEx:function(e,t){Kt.processCommand(e,t)},defineMotion:B,defineAction:K,defineOperator:O,mapCommand:Qe,_mapCommand:qe,defineRegister:T,exitVisualMode:le,exitInsertMode:$e};A.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},A.prototype.getRepeat=function(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(""),10))),e},L.prototype={setText:function(e,t,r){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!r},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(kt(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},R.prototype={pushText:function(e,t,r,n,o){n&&"\n"==r.charAt(0)&&(r=r.slice(1)+"\n"),n&&"\n"!==r.charAt(r.length-1)&&(r+="\n");var i=this.isValidRegister(e)?this.getRegister(e):null;if(!i){switch(t){case"yank":this.registers[0]=new L(r,n,o);break;case"delete":case"change":-1==r.indexOf("\n")?this.registers["-"]=new L(r,n):(this.shiftNumericRegisters_(),this.registers[1]=new L(r,n))}return void this.unnamedRegister.setText(r,n,o)}var a=g(e);a?i.pushText(r,n):i.setText(r,n,o),this.unnamedRegister.setText(i.toString(),n)},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new L),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&y(e,gt)},shiftNumericRegisters_:function(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(""+(e-1))}},E.prototype={nextMatch:function(e,t){var r=this.historyBuffer,n=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var o=this.iterator+n;t?o>=0:o<r.length;o+=n)for(var i=r[o],a=0;a<=i.length;a++)if(this.initialPrefix==i.substring(0,a))return this.iterator=o,i;return o>=r.length?(this.iterator=r.length,this.initialPrefix):0>o?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var xt={matchCommand:function(e,t,r,n){var o=W(e,t,n,r);if(!o.full&&!o.partial)return{type:"none"};if(!o.full&&o.partial)return{type:"partial"};for(var i,a=0;a<o.full.length;a++){var s=o.full[a];i||(i=s)}return"<character>"==i.keys.slice(-11)&&(r.selectedCharacter=_(e)),{type:"full",command:i}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=P(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);b(e)}n.operator=r.operator,n.operatorArgs=P(r.operatorArgs),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=P(r.operatorMotionArgs);o&&n&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,o=n.getRepeat(),i=!!o,a=P(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=o||1,a.repeatIsExplicit=i,a.registerName=n.registerName,b(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),bt[r.action](e,a,t)},processSearch:function(t,r,n){function o(e,o,i){Ct.searchHistoryController.pushInput(e),Ct.searchHistoryController.reset();try{He(t,e,o,i)}catch(a){return Ke(t,"Invalid regex: "+e),void b(t)}xt.processMotion(t,r,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:n.searchArgs.toJumplist}})}function i(e){t.scrollTo(p.left,p.top),o(e,!0,!0);var r=Ct.macroModeState;r.isRecording&&Xe(r,e)}function a(r,n,o){var i,a=e.keyName(r);"Up"==a||"Down"==a?(i="Up"==a?!0:!1,n=Ct.searchHistoryController.nextMatch(n,i)||"",o(n)):"Left"!=a&&"Right"!=a&&"Ctrl"!=a&&"Alt"!=a&&"Shift"!=a&&Ct.searchHistoryController.reset();var s;try{s=He(t,n,!0,!0)}catch(r){}s?t.scrollIntoView(_e(t,!l,s),30):(De(t),t.scrollTo(p.left,p.top))}function s(r,n,o){var i=e.keyName(r);"Esc"==i||"Ctrl-C"==i||"Ctrl-["==i||"Backspace"==i&&""==n?(Ct.searchHistoryController.pushInput(n),Ct.searchHistoryController.reset(),He(t,h),De(t),t.scrollTo(p.left,p.top),e.e_stop(r),b(t),o(),t.focus()):"Ctrl-U"==i&&(e.e_stop(r),o(""))}if(t.getSearchCursor){var l=n.searchArgs.forward,c=n.searchArgs.wholeWordOnly;be(t).setReversed(!l);var u=l?"/":"?",h=be(t).getQuery(),p=t.getScrollInfo();switch(n.searchArgs.querySrc){case"prompt":var f=Ct.macroModeState;if(f.isPlaying){var d=f.replaySearchQueries.shift();o(d,!0,!1)}else Pe(t,{onClose:i,prefix:u,desc:Bt,onKeyUp:a,onKeyDown:s});break;case"wordUnderCursor":var m=pe(t,!1,!0,!1,!0),g=!0;if(m||(m=pe(t,!1,!0,!1,!1),g=!1),!m)return;var d=t.getLine(m.start.line).substring(m.start.ch,m.end.ch);d=g&&c?"\\b"+d+"\\b":G(d),Ct.jumpList.cachedCursor=t.getCursor(),t.setCursor(m.start),o(d,!0,!1)}}},processEx:function(t,r,n){function o(e){Ct.exCommandHistoryController.pushInput(e),Ct.exCommandHistoryController.reset(),Kt.processCommand(t,e)}function i(r,n,o){var i,a=e.keyName(r);("Esc"==a||"Ctrl-C"==a||"Ctrl-["==a||"Backspace"==a&&""==n)&&(Ct.exCommandHistoryController.pushInput(n),Ct.exCommandHistoryController.reset(),e.e_stop(r),b(t),o(),t.focus()),"Up"==a||"Down"==a?(i="Up"==a?!0:!1,n=Ct.exCommandHistoryController.nextMatch(n,i)||"",o(n)):"Ctrl-U"==a?(e.e_stop(r),o("")):"Left"!=a&&"Right"!=a&&"Ctrl"!=a&&"Alt"!=a&&"Shift"!=a&&Ct.exCommandHistoryController.reset()}"keyToEx"==n.type?Kt.processCommand(t,n.exArgs.input):r.visualMode?Pe(t,{onClose:o,prefix:":",value:"'<,'>",onKeyDown:i}):Pe(t,{onClose:o,prefix:":",onKeyDown:i})},evalInput:function(e,t){var r,o,i,a=t.inputState,s=a.motion,l=a.motionArgs||{},c=a.operator,u=a.operatorArgs||{},h=a.registerName,p=t.sel,f=V(t.visualMode?N(e,p.head):e.getCursor("head")),d=V(t.visualMode?N(e,p.anchor):e.getCursor("anchor")),m=V(f),g=V(d);if(c&&this.recordLastEdit(t,a),i=void 0!==a.repeatOverride?a.repeatOverride:a.getRepeat(),i>0&&l.explicitRepeat?l.repeatIsExplicit=!0:(l.noRepeat||!l.explicitRepeat&&0===i)&&(i=1,l.repeatIsExplicit=!1),a.selectedCharacter&&(l.selectedCharacter=u.selectedCharacter=a.selectedCharacter),l.repeat=i,b(e),s){var v=St[s](e,f,l,t);if(t.lastMotion=St[s],!v)return;if(l.toJumplist){var y=Ct.jumpList,k=y.cachedCursor;k?(fe(e,k,v),delete y.cachedCursor):fe(e,f,v)}v instanceof Array?(o=v[0],r=v[1]):r=v,r||(r=V(f)),t.visualMode?(t.visualBlock&&r.ch===1/0||(r=N(e,r,t.visualBlock)),o&&(o=N(e,o,!0)),o=o||g,p.anchor=o,p.head=r,ie(e),Ce(e,t,"<",J(o,r)?o:r),Ce(e,t,">",J(o,r)?r:o)):c||(r=N(e,r),e.setCursor(r.line,r.ch))}if(c){if(u.lastSel){o=g;var C=u.lastSel,w=Math.abs(C.head.line-C.anchor.line),M=Math.abs(C.head.ch-C.anchor.ch);r=C.visualLine?n(g.line+w,g.ch):C.visualBlock?n(g.line+w,g.ch+M):C.head.line==C.anchor.line?n(g.line,g.ch+M):n(g.line+w,g.ch),t.visualMode=!0,t.visualLine=C.visualLine,t.visualBlock=C.visualBlock,p=t.sel={anchor:o,head:r},ie(e)}else t.visualMode&&(u.lastSel={anchor:V(p.anchor),head:V(p.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var x,S,A,L,T;if(t.visualMode){if(x=$(p.head,p.anchor),S=q(p.head,p.anchor),A=t.visualLine||u.linewise,L=t.visualBlock?"block":A?"line":"char",T=ae(e,{anchor:x,head:S},L),A){var R=T.ranges;if("block"==L)for(var E=0;E<R.length;E++)R[E].head.ch=z(e,R[E].head.line);else"line"==L&&(R[0].head=n(R[0].head.line+1,0))}}else{if(x=V(o||g),S=V(r||m),J(S,x)){var B=x;x=S,S=B}A=l.linewise||u.linewise,A?ue(e,x,S):l.forward&&ce(e,x,S),L="char";var I=!l.inclusive||A;T=ae(e,{anchor:x,head:S},L,I)}e.setSelections(T.ranges,T.primary),t.lastMotion=null,u.repeat=i,u.registerName=h,u.linewise=A;var O=At[c](e,u,T.ranges,g,r);t.visualMode&&le(e,null!=O),O&&e.setCursor(O)}},recordLastEdit:function(e,t,r){var n=Ct.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1)}},St={moveToTopLine:function(e,t,r){var o=Ue(e).top+r.repeat-1;return n(o,he(e.getLine(o)))},moveToMiddleLine:function(e){var t=Ue(e),r=Math.floor(.5*(t.top+t.bottom));return n(r,he(e.getLine(r)))},moveToBottomLine:function(e,t,r){var o=Ue(e).bottom-r.repeat+1;return n(o,he(e.getLine(o)))},expandToLine:function(e,t,r){var o=t;return n(o.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=be(e),o=n.getQuery();if(o){var i=!r.forward;return i=n.isReversed()?!i:i,Fe(e,o),_e(e,i,o,r.repeat)}},goToMark:function(e,t,r,n){var o=n.marks[r.selectedCharacter];if(o){var i=o.find();return r.linewise?{line:i.line,ch:he(e.getLine(i.line))}:i}return null},moveToOtherHighlightedEnd:function(e,t,r,o){if(o.visualBlock&&r.sameLine){var i=o.sel;return[N(e,n(i.anchor.line,i.head.ch)),N(e,n(i.head.line,i.anchor.ch))]}return[o.sel.head,o.sel.anchor]},jumpToMark:function(e,t,r,o){for(var i=t,a=0;a<r.repeat;a++){var s=i;for(var l in o.marks)if(f(l)){var c=o.marks[l].find(),u=r.forward?J(c,s):J(s,c);if(!(u||r.linewise&&c.line==s.line)){var h=U(s,i),p=r.forward?Q(s,c,i):Q(i,c,s);(h||p)&&(i=c)}}}return r.linewise&&(i=n(i.line,he(e.getLine(i.line)))),i},moveByCharacters:function(e,t,r){var o=t,i=r.repeat,a=r.forward?o.ch+i:o.ch-i;return n(o.line,a)},moveByLines:function(e,t,r,o){var i=t,a=i.ch;switch(o.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:a=o.lastHPos;break;default:o.lastHPos=a}var s=r.repeat+(r.repeatOffset||0),l=r.forward?i.line+s:i.line-s,c=e.firstLine(),u=e.lastLine();return c>l&&i.line==c||l>u&&i.line==u?void 0:(r.toFirstChar&&(a=he(e.getLine(l)),o.lastHPos=a),o.lastHSPos=e.charCoords(n(l,a),"div").left,n(l,a))},moveByDisplayLines:function(e,t,r,o){var i=t;switch(o.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:o.lastHSPos=e.charCoords(i,"div").left}var a=r.repeat,s=e.findPosV(i,r.forward?a:-a,"line",o.lastHSPos);if(s.hitSide)if(r.forward)var l=e.charCoords(s,"div"),c={top:l.top+8,left:o.lastHSPos},s=e.coordsChar(c,"div");else{var u=e.charCoords(n(e.firstLine(),0),"div");u.left=o.lastHSPos,s=e.coordsChar(u,"div")}return o.lastHPos=s.ch,s},moveByPage:function(e,t,r){var n=t,o=r.repeat;return e.findPosV(n,r.forward?o:-o,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return Me(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var o=e.getScrollInfo(),i=null,a=r.repeat;a||(a=o.clientHeight/(2*e.defaultTextHeight()));var s=e.charCoords(t,"local");r.repeat=a;var i=St.moveByDisplayLines(e,t,r,n);if(!i)return null;var l=e.charCoords(i,"local");return e.scrollTo(null,o.top+l.top-s.top),i},moveByWords:function(e,t,r){return ve(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,o=ye(e,n,r.forward,r.selectedCharacter),i=r.forward?-1:1;return de(i,r),o?(o.ch+=i,o):null},moveToCharacter:function(e,t,r){var n=r.repeat;return de(0,r),ye(e,n,r.forward,r.selectedCharacter)||t},moveToSymbol:function(e,t,r){var n=r.repeat;return me(e,n,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var o=r.repeat;return n.lastHPos=o-1,n.lastHSPos=e.charCoords(t,"div").left,ke(e,o)},moveToEol:function(e,t,r,o){var i=t;o.lastHPos=1/0;var a=n(i.line+r.repeat-1,1/0),s=e.clipPos(a);return s.ch--,o.lastHSPos=e.charCoords(s,"div").left,a},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return n(r.line,he(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){var r,o=t,i=o.line,a=o.ch,s=e.getLine(i);do if(r=s.charAt(a++),r&&d(r)){var l=e.getTokenTypeAt(n(i,a));if("string"!==l&&"comment"!==l)break}while(r);if(r){var c=e.findMatchingBracket(n(i,a));return c.to}return o},moveToStartOfLine:function(e,t){return n(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var o=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(o=r.repeat-e.getOption("firstLineNumber")),n(o,he(e.getLine(o)))},textObjectManipulation:function(e,t,r,n){var o={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},i={"'":!0,'"':!0},a=r.selectedCharacter;"b"==a?a="(":"B"==a&&(a="{");var s,l=!r.textObjectInner;if(o[a])s=xe(e,t,a,l);else if(i[a])s=Se(e,t,a,l);else if("W"===a)s=pe(e,l,!0,!0);else if("w"===a)s=pe(e,l,!0,!1);else{if("p"!==a)return null;if(s=Me(e,t,r.repeat,0,l),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var c=n.inputState.operatorArgs;c&&(c.linewise=!0),s.end.line--}}return e.state.vim.visualMode?oe(e,s.start,s.end):[s.start,s.end]},repeatLastCharacterSearch:function(e,t,r){var n=Ct.lastChararacterSearch,o=r.repeat,i=r.forward===n.forward,a=(n.increment?1:0)*(i?-1:1);e.moveH(-a,"char"),r.inclusive=i?!0:!1;var s=ye(e,o,i,n.selectedCharacter);return s?(s.ch+=a,s):(e.moveH(a,"char"),t)}},At={change:function(t,r,o){var i,a,s=t.state.vim;if(Ct.macroModeState.lastInsertModeChanges.inVisualBlock=s.visualBlock,s.visualMode){a=t.getSelection();var l=I("",o.length);t.replaceSelections(l),i=$(o[0].head,o[0].anchor)}else{var c=o[0].anchor,u=o[0].head;a=t.getRange(c,u);var h=s.lastEditInputState||{};if("moveByWords"==h.motion&&!v(a)){var p=/\s+$/.exec(a);p&&h.motionArgs&&h.motionArgs.forward&&(u=j(u,0,-p[0].length),a=a.slice(0,-p[0].length))}var f=new n(c.line-1,Number.MAX_VALUE),d=t.firstLine()==t.lastLine();u.line>t.lastLine()&&r.linewise&&!d?t.replaceRange("",f,u):t.replaceRange("",c,u),r.linewise&&(d||(t.setCursor(f),e.commands.newlineAndIndent(t)),c.ch=Number.MAX_VALUE),i=c}Ct.registerController.pushText(r.registerName,"change",a,r.linewise,o.length>1),bt.enterInsertMode(t,{head:i},t.state.vim)},"delete":function(e,t,r){var o,i,a=e.state.vim;if(a.visualBlock){i=e.getSelection();var s=I("",r.length);e.replaceSelections(s),o=r[0].anchor}else{var l=r[0].anchor,c=r[0].head;t.linewise&&c.line!=e.firstLine()&&l.line==e.lastLine()&&l.line==c.line-1&&(l.line==e.firstLine()?l.ch=0:l=n(l.line-1,z(e,l.line-1))),i=e.getRange(l,c),e.replaceRange("",l,c),o=l,t.linewise&&(o=St.moveToFirstNonWhiteSpaceCharacter(e,l))}return Ct.registerController.pushText(t.registerName,"delete",i,t.linewise,a.visualBlock),N(e,o)},indent:function(e,t,r){var n=e.state.vim,o=r[0].anchor.line,i=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line,a=n.visualMode?t.repeat:1;t.linewise&&i--;for(var s=o;i>=s;s++)for(var l=0;a>l;l++)e.indentLine(s,t.indentRight);return St.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},changeCase:function(e,t,r,n,o){for(var i=e.getSelections(),a=[],s=t.toLower,l=0;l<i.length;l++){var c=i[l],u="";if(s===!0)u=c.toLowerCase();else if(s===!1)u=c.toUpperCase();else for(var h=0;h<c.length;h++){var p=c.charAt(h);u+=g(p)?p.toLowerCase():p.toUpperCase()}a.push(u)}return e.replaceSelections(a),t.shouldMoveCursor?o:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?St.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:$(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var o=e.state.vim,i=e.getSelection(),a=o.visualMode?$(o.sel.anchor,o.sel.head,r[0].head,r[0].anchor):n;return Ct.registerController.pushText(t.registerName,"yank",i,t.linewise,o.visualBlock),a}},bt={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat,o=t.forward,i=Ct.jumpList,a=i.move(e,o?n:-n),s=a?a.find():void 0;s=s?s:e.getCursor(),e.setCursor(s)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=e.defaultTextHeight(),i=e.getScrollInfo().top,a=o*n,s=t.forward?i+a:i-a,l=V(e.getCursor()),c=e.charCoords(l,"local");if(t.forward)s>c.top?(l.line+=(s-c.top)/o,l.line=Math.ceil(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,s);else{var u=s+e.getScrollInfo().clientHeight;u<c.bottom?(l.line-=(c.bottom-u)/o,l.line=Math.floor(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,s)}}},scrollToCursor:function(e,t){var r=e.getCursor().line,o=e.charCoords(n(r,0),"local"),i=e.getScrollInfo().clientHeight,a=o.top,s=o.bottom-a;switch(t.position){case"center":a=a-i/2+s;break;case"bottom":a=a-i+s}e.scrollTo(null,a)},replayMacro:function(e,t,r){var n=t.selectedCharacter,o=t.repeat,i=Ct.macroModeState;for("@"==n&&(n=i.latestRegister);o--;)ze(e,r,i,n)},enterMacroRecordMode:function(e,t){var r=Ct.macroModeState,n=t.selectedCharacter;r.enterMacroRecordMode(e,n)},enterInsertMode:function(t,r,o){if(!t.getOption("readOnly")){o.insertMode=!0,o.insertModeRepeat=r&&r.repeat||1;var i=r?r.insertAt:null,a=o.sel,s=r.head||t.getCursor("head"),l=t.listSelections().length;if("eol"==i)s=n(s.line,z(t,s.line));else if("charAfter"==i)s=j(s,0,1);else if("firstNonBlank"==i)s=St.moveToFirstNonWhiteSpaceCharacter(t,s);else if("startOfSelectedArea"==i)o.visualBlock?(s=n(Math.min(a.head.line,a.anchor.line),Math.min(a.head.ch,a.anchor.ch)),l=Math.abs(a.head.line-a.anchor.line)+1):s=a.head.line<a.anchor.line?a.head:n(a.anchor.line,0);else if("endOfSelectedArea"==i)o.visualBlock?(s=n(Math.min(a.head.line,a.anchor.line),Math.max(a.head.ch+1,a.anchor.ch)),l=Math.abs(a.head.line-a.anchor.line)+1):s=a.head.line>=a.anchor.line?j(a.head,0,1):n(a.anchor.line,0);else if("inplace"==i&&o.visualMode)return;t.setOption("keyMap","vim-insert"),t.setOption("disableInput",!1),r&&r.replace?(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"})):(t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})),Ct.macroModeState.isPlaying||(t.on("change",Ye),e.on(t.getInputField(),"keydown",ot)),o.visualMode&&le(t),ee(t,s,l)}},toggleVisualMode:function(t,r,o){var i,a=r.repeat,s=t.getCursor();o.visualMode?o.visualLine^r.linewise||o.visualBlock^r.blockwise?(o.visualLine=!!r.linewise,o.visualBlock=!!r.blockwise,e.signal(t,"vim-mode-change",{mode:"visual",subMode:o.visualLine?"linewise":o.visualBlock?"blockwise":""}),ie(t)):le(t):(o.visualMode=!0,o.visualLine=!!r.linewise,o.visualBlock=!!r.blockwise,i=N(t,n(s.line,s.ch+a-1),!0),o.sel={anchor:s,head:i},e.signal(t,"vim-mode-change",{mode:"visual",subMode:o.visualLine?"linewise":o.visualBlock?"blockwise":""}),ie(t),Ce(t,o,"<",$(s,i)),Ce(t,o,">",q(s,i)))},reselectLastSelection:function(t,r,n){var o=n.lastSelection;if(n.visualMode&&ne(t,n),o){var i=o.anchorMark.find(),a=o.headMark.find();if(!i||!a)return;n.sel={anchor:i,head:a},n.visualMode=!0,n.visualLine=o.visualLine,n.visualBlock=o.visualBlock,ie(t),Ce(t,n,"<",$(i,a)),Ce(t,n,">",q(i,a)),e.signal(t,"vim-mode-change",{mode:"visual",subMode:n.visualLine?"linewise":n.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var o,i;if(r.visualMode){if(o=e.getCursor("anchor"),i=e.getCursor("head"),J(i,o)){var a=i;i=o,o=a}i.ch=z(e,i.line)-1}else{var s=Math.max(t.repeat,2);o=e.getCursor(),i=N(e,n(o.line+s-1,1/0))}for(var l=0,c=o.line;c<i.line;c++){l=z(e,o.line);var a=n(o.line+1,z(e,o.line+1)),u=e.getRange(o,a);u=u.replace(/\n\s*/g," "),e.replaceRange(u,o,a)}var h=n(o.line,l);r.visualMode&&le(e,!1),e.setCursor(h)},newLineAndEnterInsertMode:function(t,r,o){o.insertMode=!0;var i=V(t.getCursor());if(i.line!==t.firstLine()||r.after){i.line=r.after?i.line:i.line-1,i.ch=z(t,i.line),t.setCursor(i);var a=e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent;a(t)}else t.replaceRange("\n",n(t.firstLine(),0)),t.setCursor(t.firstLine(),0);this.enterInsertMode(t,{repeat:r.repeat},o)},paste:function(e,t,r){var o=V(e.getCursor()),i=Ct.registerController.getRegister(t.registerName),a=i.toString();if(a){if(t.matchIndent){var s=e.getOption("tabSize"),l=function(e){var t=e.split("	").length-1,r=e.split(" ").length-1;return t*s+1*r},c=e.getLine(e.getCursor().line),u=l(c.match(/^\s*/)[0]),h=a.replace(/\n$/,""),p=a!==h,f=l(a.match(/^\s*/)[0]),a=h.replace(/^\s*/gm,function(t){var r=u+(l(t)-f);if(0>r)return"";if(e.getOption("indentWithTabs")){var n=Math.floor(r/s);return Array(n+1).join("	")}return Array(r+1).join(" ")});a+=p?"\n":""}if(t.repeat>1)var a=Array(t.repeat+1).join(a);var d=i.linewise,m=i.blockwise;if(d)r.visualMode?a=r.visualLine?a.slice(0,-1):"\n"+a.slice(0,a.length-1)+"\n":t.after?(a="\n"+a.slice(0,a.length-1),o.ch=z(e,o.line)):o.ch=0;else{if(m){a=a.split("\n");for(var g=0;g<a.length;g++)a[g]=""==a[g]?" ":a[g]}o.ch+=t.after?1:0}var v,y;if(r.visualMode){r.lastPastedText=a;var k,C=re(e,r),w=C[0],M=C[1],x=e.getSelection(),S=e.listSelections(),A=new Array(S.length).join("1").split("1");r.lastSelection&&(k=r.lastSelection.headMark.find()),Ct.registerController.unnamedRegister.setText(x),m?(e.replaceSelections(A),M=n(w.line+a.length-1,w.ch),e.setCursor(w),Y(e,M),e.replaceSelections(a),v=w):r.visualBlock?(e.replaceSelections(A),e.setCursor(w),e.replaceRange(a,w,w),v=w):(e.replaceRange(a,w,M),v=e.posFromIndex(e.indexFromPos(w)+a.length-1)),k&&(r.lastSelection.headMark=e.setBookmark(k)),d&&(v.ch=0)}else if(m){e.setCursor(o);for(var g=0;g<a.length;g++){var b=o.line+g;b>e.lastLine()&&e.replaceRange("\n",n(b,0));var L=z(e,b);L<o.ch&&X(e,b,o.ch)}e.setCursor(o),Y(e,n(o.line+a.length-1,o.ch)),e.replaceSelections(a),v=o}else e.replaceRange(a,o),d&&t.after?v=n(o.line+1,he(e.getLine(o.line+1))):d&&!t.after?v=n(o.line,he(e.getLine(o.line))):!d&&t.after?(y=e.indexFromPos(o),v=e.posFromIndex(y+a.length-1)):(y=e.indexFromPos(o),v=e.posFromIndex(y+a.length));r.visualMode&&le(e,!1),e.setCursor(v)}},undo:function(t,r){t.operation(function(){D(t,e.commands.undo,r.repeat)(),t.setCursor(t.getCursor("anchor"))})},redo:function(t,r){D(t,e.commands.redo,r.repeat)()},setRegister:function(e,t,r){r.inputState.registerName=t.selectedCharacter},setMark:function(e,t,r){var n=t.selectedCharacter;Ce(e,r,n,e.getCursor())},replace:function(t,r,o){var i,a,s=r.selectedCharacter,l=t.getCursor(),c=t.listSelections();if(o.visualMode)l=t.getCursor("start"),a=t.getCursor("end");else{var u=t.getLine(l.line);i=l.ch+r.repeat,i>u.length&&(i=u.length),a=n(l.line,i)}if("\n"==s)o.visualMode||t.replaceRange("",l,a),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t);else{var h=t.getRange(l,a);if(h=h.replace(/[^\n]/g,s),o.visualBlock){var p=new Array(t.getOption("tabSize")+1).join(" ");h=t.getSelection(),h=h.replace(/\t/g,p).replace(/[^\n]/g,s).split("\n"),t.replaceSelections(h)}else t.replaceRange(h,l,a);o.visualMode?(l=J(c[0].anchor,c[0].head)?c[0].anchor:c[0].head,t.setCursor(l),le(t,!1)):t.setCursor(j(a,0,-1))}},incrementNumberToken:function(e,t){for(var r,o,i,a,s,l=e.getCursor(),c=e.getLine(l.line),u=/-?\d+/g;null!==(r=u.exec(c))&&(s=r[0],o=r.index,i=o+s.length,!(l.ch<i)););if((t.backtrack||!(i<=l.ch))&&s){var h=t.increase?1:-1,p=parseInt(s)+h*t.repeat,f=n(l.line,o),d=n(l.line,i);a=p.toString(),e.replaceRange(a,f,d),e.setCursor(n(l.line,o+a.length-1))}},repeatLastEdit:function(e,t,r){var n=r.lastEditInputState;if(n){var o=t.repeat;o&&t.repeatIsExplicit?r.lastEditInputState.repeatOverride=o:o=r.lastEditInputState.repeatOverride||o,it(e,r,o,!1)}},exitInsertMode:$e},Lt={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},Tt={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return 0===e.index&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t="*"===e.lastCh&&"/"===e.nextCh;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb="m"===e.symb?"{":"}",e.reverseSymb="{"===e.symb?"}":"{"},isComplete:function(e){return e.nextCh===e.symb?!0:!1}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if("#"===e.nextCh){var t=e.lineText.match(/#(\w+)/)[1];if("endif"===t){if(e.forward&&0===e.depth)return!0;e.depth++}else if("if"===t){if(!e.forward&&0===e.depth)return!0;e.depth--}if("else"===t&&0===e.depth)return!0}return!1}}};k("pcre",!0,"boolean"),Ae.prototype={getQuery:function(){return Ct.query},setQuery:function(e){Ct.query=e},getOverlay:function(){return this.searchOverlay},setOverlay:function(e){this.searchOverlay=e},isReversed:function(){return Ct.isReversed},setReversed:function(e){Ct.isReversed=e},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(e){this.annotate=e}};var Rt={"\\n":"\n","\\r":"\r","\\t":"	"},Et={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"	"},Bt="(Javascript regexp)",It=function(){this.buildCommandMap_()};It.prototype={processCommand:function(e,t,r){var n=this;e.operation(function(){
  e.curOp.isVimOp=!0,n._processCommand(e,t,r)})},_processCommand:function(t,r,n){var o=t.state.vim,i=Ct.registerController.getRegister(":"),a=i.toString();o.visualMode&&le(t);var s=new e.StringStream(r);i.setText(r);var l=n||{};l.input=r;try{this.parseInput_(t,s,l)}catch(c){throw Ke(t,c),c}var u,h;if(l.commandName){if(u=this.matchCommand_(l.commandName)){if(h=u.name,u.excludeFromCommandHistory&&i.setText(a),this.parseCommandArgs_(s,l,u),"exToKey"==u.type){for(var p=0;p<u.toKeys.length;p++)e.Vim.handleKey(t,u.toKeys[p],"mapping");return}if("exToEx"==u.type)return void this.processCommand(t,u.toInput)}}else void 0!==l.line&&(h="move");if(!h)return void Ke(t,'Not an editor command ":'+r+'"');try{Ot[h](t,l),u&&u.possiblyAsync||!l.callback||l.callback()}catch(c){throw Ke(t,c),c}},parseInput_:function(e,t,r){t.eatWhile(":"),t.eat("%")?(r.line=e.firstLine(),r.lineEnd=e.lastLine()):(r.line=this.parseLineSpec_(e,t),void 0!==r.line&&t.eat(",")&&(r.lineEnd=this.parseLineSpec_(e,t)));var n=t.match(/^(\w+)/);return n?r.commandName=n[1]:r.commandName=t.match(/.*/)[0],r},parseLineSpec_:function(e,t){var r=t.match(/^(\d+)/);if(r)return parseInt(r[1],10)-1;switch(t.next()){case".":return e.getCursor().line;case"$":return e.lastLine();case"'":var n=e.state.vim.marks[t.next()];if(n&&n.find())return n.find().line;throw new Error("Mark not set");default:return void t.backUp(1)}},parseCommandArgs_:function(e,t,r){if(!e.eol()){t.argString=e.match(/.*/)[0];var n=r.argDelimiter||/\s+/,o=Z(t.argString).split(n);o.length&&o[0]&&(t.args=o)}},matchCommand_:function(e){for(var t=e.length;t>0;t--){var r=e.substring(0,t);if(this.commandMap_[r]){var n=this.commandMap_[r];if(0===n.name.indexOf(e))return n}}return null},buildCommandMap_:function(){this.commandMap_={};for(var e=0;e<r.length;e++){var t=r[e],n=t.shortName||t.name;this.commandMap_[n]=t}},map:function(e,r,n){if(":"!=e&&":"==e.charAt(0)){if(n)throw Error("Mode not supported for ex mappings");var o=e.substring(1);":"!=r&&":"==r.charAt(0)?this.commandMap_[o]={name:o,type:"exToEx",toInput:r.substring(1),user:!0}:this.commandMap_[o]={name:o,type:"exToKey",toKeys:r,user:!0}}else if(":"!=r&&":"==r.charAt(0)){var i={keys:e,type:"keyToEx",exArgs:{input:r.substring(1)},user:!0};n&&(i.context=n),t.unshift(i)}else{var i={keys:e,type:"keyToKey",toKeys:r,user:!0};n&&(i.context=n),t.unshift(i)}},unmap:function(e,r){if(":"!=e&&":"==e.charAt(0)){if(r)throw Error("Mode not supported for ex mappings");var n=e.substring(1);if(this.commandMap_[n]&&this.commandMap_[n].user)return void delete this.commandMap_[n]}else for(var o=e,i=0;i<t.length;i++)if(o==t[i].keys&&t[i].context===r&&t[i].user)return void t.splice(i,1);throw Error("No such mapping.")}};var Ot={colorscheme:function(e,t){return!t.args||t.args.length<1?void Ke(e,e.getOption("theme")):void e.setOption("theme",t.args[0])},map:function(e,t,r){var n=t.args;return!n||n.length<2?void(e&&Ke(e,"Invalid mapping: "+t.input)):void Kt.map(n[0],n[1],r)},imap:function(e,t){this.map(e,t,"insert")},nmap:function(e,t){this.map(e,t,"normal")},vmap:function(e,t){this.map(e,t,"visual")},unmap:function(e,t,r){var n=t.args;return!n||n.length<1?void(e&&Ke(e,"No such mapping: "+t.input)):void Kt.unmap(n[0],r)},move:function(e,t){xt.processCommand(e,e.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var r=t.args,n=t.setCfg||{};if(!r||r.length<1)return void(e&&Ke(e,"Invalid mapping: "+t.input));var o=r[0].split("="),i=o[0],a=o[1],s=!1;if("?"==i.charAt(i.length-1)){if(a)throw Error("Trailing characters: "+t.argString);i=i.substring(0,i.length-1),s=!0}void 0===a&&"no"==i.substring(0,2)&&(i=i.substring(2),a=!1);var l=vt[i]&&"boolean"==vt[i].type;if(l&&void 0==a&&(a=!0),!l&&void 0===a||s){var c=w(i,e,n);c===!0||c===!1?Ke(e," "+(c?"":"no")+i):Ke(e,"  "+i+"="+c)}else C(i,a,e,n)},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=Ct.registerController.registers,o="----------Registers----------<br><br>";if(r){var i;r=r.join("");for(var a=0;a<r.length;a++)if(i=r.charAt(a),Ct.registerController.isValidRegister(i)){var s=n[i]||new L;o+='"'+i+"    "+s.toString()+"<br>"}}else for(var i in n){var l=n[i].toString();l.length&&(o+='"'+i+"    "+l+"<br>")}Ke(e,o)},sort:function(t,r){function o(){if(r.argString){var t=new e.StringStream(r.argString);if(t.eat("!")&&(a=!0),t.eol())return;if(!t.eatSpace())return"Invalid arguments";var n=t.match(/[a-z]+/);if(n){n=n[0],s=-1!=n.indexOf("i"),l=-1!=n.indexOf("u");var o=-1!=n.indexOf("d")&&1,i=-1!=n.indexOf("x")&&1,u=-1!=n.indexOf("o")&&1;if(o+i+u>1)return"Invalid arguments";c=o&&"decimal"||i&&"hex"||u&&"octal"}if(t.match(/\/.*\//))return"patterns not supported"}}function i(e,t){if(a){var r;r=e,e=t,t=r}s&&(e=e.toLowerCase(),t=t.toLowerCase());var n=c&&g.exec(e),o=c&&g.exec(t);return n?(n=parseInt((n[1]+n[2]).toLowerCase(),v),o=parseInt((o[1]+o[2]).toLowerCase(),v),n-o):t>e?-1:1}var a,s,l,c,u=o();if(u)return void Ke(t,u+": "+r.argString);var h=r.line||t.firstLine(),p=r.lineEnd||r.line||t.lastLine();if(h!=p){var f=n(h,0),d=n(p,z(t,p)),m=t.getRange(f,d).split("\n"),g="decimal"==c?/(-?)([\d]+)/:"hex"==c?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==c?/([0-7]+)/:null,v="decimal"==c?10:"hex"==c?16:"octal"==c?8:null,y=[],k=[];if(c)for(var C=0;C<m.length;C++)g.exec(m[C])?y.push(m[C]):k.push(m[C]);else k=m;if(y.sort(i),k.sort(i),m=a?y.concat(k):k.concat(y),l){var w,M=m;m=[];for(var C=0;C<M.length;C++)M[C]!=w&&m.push(M[C]),w=M[C]}t.replaceRange(m.join("\n"),f,d)}},global:function(e,t){var r=t.argString;if(!r)return void Ke(e,"Regular Expression missing from global");var n,o=void 0!==t.line?t.line:e.firstLine(),i=t.lineEnd||t.line||e.lastLine(),a=Te(r),s=r;if(a.length&&(s=a[0],n=a.slice(1,a.length).join("/")),s)try{He(e,s,!0,!0)}catch(l){return void Ke(e,"Invalid regex: "+s)}for(var c=be(e).getQuery(),u=[],h="",p=o;i>=p;p++){var f=c.test(e.getLine(p));f&&(u.push(p+1),h+=e.getLine(p)+"<br>")}if(!n)return void Ke(e,h);var d=0,m=function(){if(d<u.length){var t=u[d]+n;Kt.processCommand(e,t,{callback:m})}d++};m()},substitute:function(e,t){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var r,o,i,a,s=t.argString,l=s?Te(s):[],c="",u=!1,h=!1;if(l.length)r=l[0],c=l[1],void 0!==c&&(c=w("pcre")?Ie(c):Be(c),Ct.lastSubstituteReplacePart=c),o=l[2]?l[2].split(" "):[];else if(s&&s.length)return void Ke(e,"Substitutions should be of the form :s/pattern/replace/");if(o&&(i=o[0],a=parseInt(o[1]),i&&(-1!=i.indexOf("c")&&(u=!0,i.replace("c","")),-1!=i.indexOf("g")&&(h=!0,i.replace("g","")),r=r+"/"+i)),r)try{He(e,r,!0,!0)}catch(p){return void Ke(e,"Invalid regex: "+r)}if(c=c||Ct.lastSubstituteReplacePart,void 0===c)return void Ke(e,"No previous substitute regular expression");var f=be(e),d=f.getQuery(),m=void 0!==t.line?t.line:e.getCursor().line,g=t.lineEnd||m;m==e.firstLine()&&g==e.lastLine()&&(g=1/0),a&&(m=g,g=m+a-1);var v=N(e,n(m,0)),y=e.getSearchCursor(d,v);Je(e,u,h,m,g,y,d,c,t.callback)},redo:e.commands.redo,undo:e.commands.undo,write:function(t){e.commands.save?e.commands.save(t):t.save()},nohlsearch:function(e){De(e)},delmarks:function(t,r){if(!r.argString||!Z(r.argString))return void Ke(t,"Argument required");for(var n=t.state.vim,o=new e.StringStream(Z(r.argString));!o.eol();){o.eatSpace();var i=o.pos;if(!o.match(/[a-zA-Z]/,!1))return void Ke(t,"Invalid argument: "+r.argString.substring(i));var a=o.next();if(o.match("-",!0)){if(!o.match(/[a-zA-Z]/,!1))return void Ke(t,"Invalid argument: "+r.argString.substring(i));var s=a,l=o.next();if(!(f(s)&&f(l)||g(s)&&g(l)))return void Ke(t,"Invalid argument: "+s+"-");var c=s.charCodeAt(0),u=l.charCodeAt(0);if(c>=u)return void Ke(t,"Invalid argument: "+r.argString.substring(i));for(var h=0;u-c>=h;h++){var p=String.fromCharCode(c+h);delete n.marks[p]}}else delete n.marks[a]}}},Kt=new It;return e.keyMap.vim={attach:s,detach:a,call:l},k("insertModeEscKeysTimeout",200,"number"),e.keyMap["vim-insert"]={"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(t){var r=e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent;r(t)},fallthrough:["default"],attach:s,detach:a,call:l},e.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:s,detach:a,call:l},S(),Mt};e.Vim=o()});