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