[
  {
    "path": ".gitignore",
    "content": ".DS_Store\nout\nnode_modules"
  },
  {
    "path": ".vscode/launch.json",
    "content": "// A launch configuration that compiles the extension and then opens it inside a new window\n{\n    \"version\": \"0.1.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Launch Extension\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outFiles\": [\"${workspaceRoot}/out/src/**/*.js\"],\n            \"preLaunchTask\": \"npm\"\n        },\n        {\n            \"name\": \"Extension Tests\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\n\t\t\t\t\"--extensionDevelopmentPath=${workspaceRoot}\", \n\t\t\t\t\"--extensionTestsPath=${workspaceRoot}/out/test\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outFiles\": [\n\t\t\t\t\"${workspaceRoot}/out/src/**/*.js\", \n\t\t\t\t\"${workspaceRoot}/out/test/**/*.js\"],\n            \"preLaunchTask\": \"npm\"\n        }\n    ]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "// Place your settings in this file to overwrite default and user settings.\n{\n    \"files.exclude\": {\n        \"out\": false // set this to true to hide the \"out\" folder with the compiled JS files\n    },\n    \"search.exclude\": {\n        \"out\": true // set this to false to include \"out\" folder in search results\n    },\n    \"typescript.tsdk\": \"./node_modules/typescript/lib\" // we want to use the TS server from our node_modules folder to control its version\n}"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "// Available variables which can be used inside of strings.\n// ${workspaceRoot}: the root folder of the team\n// ${file}: the current opened file\n// ${fileBasename}: the current opened file's basename\n// ${fileDirname}: the current opened file's dirname\n// ${fileExtname}: the current opened file's extension\n// ${cwd}: the current working directory of the spawned process\n\n// A task runner that calls a custom npm script that compiles the extension.\n{\n    \"version\": \"0.1.0\",\n\n    // we want to run npm\n    \"command\": \"npm\",\n\n    // the command is a shell script\n    \"isShellCommand\": true,\n\n    // show the output window only if unrecognized errors occur.\n    \"showOutput\": \"silent\",\n\n    // we run the custom script \"compile\" as defined in package.json\n    \"args\": [\"run\", \"compile\", \"--loglevel\", \"silent\"],\n\n    // The tsc compiler is started in background mode\n    \"isBackground\": true,\n\n    // use the standard tsc in watch mode problem matcher to find compile problems in the output.\n    \"problemMatcher\": \"$tsc-watch\"\n}"
  },
  {
    "path": ".vscodeignore",
    "content": ".vscode/**\n.vscode-test/**\nout/test/**\ntest/**\nsrc/**\n**/*.map\n.gitignore\ntsconfig.json\nvsc-extension-quickstart.md\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## 0.9.0 (2019-05-06)\n- Fixed focus and movement keys interaction when find widget is open\n- Fixed movement keys in terminal\n- Bound Ctrl-o to insert line before\n- Fixed multi-cursor handling and Ctrl-g\n- Fixed remote development issues caused by clipboardy\n- Added C-_ as undo\n- Added C-x r as open recent (was C-r and overridden)\n- Fixed split window behavior to better resemble emacs\n\n## 0.8.2 (2017-10-09)\n- Fix replaceOne shortcut to correctly only replace the currently selected match\n\n## 0.8.1 (2017-10-09)\n- Do not close search widgtet on horizontal movement\n- Add shortcut for replace.\n- Add shortcuts for jump-to-next-error and jump-to-previous-error\n- Fix precondition for deleteWordLeft\n\n## 0.8.0 (2017-08-11)\n- Removed register mode, it was introducing too much typing latency\n- Extend C-l to also position cursor at top / center / bottom of viewport\n- Fix C-f to work in integrated terminal\n\n## 0.7.0 (2017-07-15)\n- Change C-j to behave as similar as possible as ENTER\n- Add C-m as a C-j alias (in early emacs versions C-m breaks the line, not C-j)\n- Add missing M-backspace shortcut to delete left word\n- Fix C-p and C-e shortcuts to work on the integrated terminal, instead of opening the command palette\n\n## 0.6.1 (2017-06-27)\n- Fix cut to end of line operation when on the last line of a file\n\n## 0.6.0 (2017-06-26)\n- Continuous kills from the same cursor position will augment clipboard\n- Killing removes end of line character when only whitespace is left on line\n- Bind toggle zen mode to C-x z, the default was conflicting\n- Close search widget on many cursor moves & other editor actions\n\n## 0.5.0 (2017-03-25)\n- Added bindings to manipulate window splitting and joining\n\n## 0.4.0 (2017-03-16)\n- Using clipboardy for system clipboard access, old dependency does not work on linux.\n\n## 0.3.2 (2017-03-10)\n- Added icon\n\n## 0.3.0 (2017-03-09)\n- Repackaged and republished for ease of access on vscode marketplace.\n\n## 0.2.0 (2017-01-14)\n- Forked and merged various pull requests and fixes\n- The clipboard handling is simplified by the removal of the emacs-only kill ring (which was also an unfinished implementation in the original). Copy, Cut, Yank and C-K work with the system clipboard now.\n- C+x k to close tab, C+x C-k all tabs\n- C+l centers screen on the cursor line\n- C+x C+f bound to quick open file\n- yank overwrites selection\n\n## 0.1.1 (2016-11-04)\n- Fix #24: C-g does not cancel suggestions and prompts\n- Update vscode engine\n\n## 0.1.0\n- Fix: IntelliSense Suggestion.\n- Add C-x b.\n\n## 0.0.10 (2016-08-29)\n- Fix #18: Add Esc to step out from mark mode.\n- Add C-x C-o.\n- Fix: do not enter automatically in Mark Mode after Yanking. \n\n## 0.0.9 (2016-07-24)\n- Add Kill-ring.\n- Alt-x show commands palette.\n\nAll changes written by gizak, sammy44nts. Thanks\n\n## 0.0.7 (2016-07-14)\n- bug fix for C-k. **Thanks trezm.**\n- C-x C-f execute \"workbench.action.files.openFile\".\n\nThanks sammy44nts.\n\n## 0.0.6\n- C-p and C-n can be used in other panels such as Suggestion and Hint.\n- Fix bug C-x C-f won't open file explorer.\n- Add one more undo operation C-/\n- Add redo operation C-x z\n- Fix incorrect column moving after using C-a and C-e\n\nThese commands and bug fixes were coding by kpping. Thanks. :)\n\n## 0.0.5\n- Change the processing of C-u, C-h.\n- Change the processing of C-x C-f, C-x C-w, C-x C-s.\n\n## 0.0.4\n- Modify the search operation.\n\n## 0.0.3\n- Fixed a bug that occurred when you start from the command line.\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# vscode-emacs-friendly\n\nThis plugin provides emacs keybindings and workflow for Visual Studio Code and is a fork of the great vscode extension by [hiro-sun](https://github.com/hiro-sun/vscode-emacs).\n\nIt merges some of the pull requests in the original and other external helpers that make the extension a little less an exact copy of emacs behavior, and a little more friendly in interacting with the system clipboard and normal vscode interactions.\n\nThe following are some of the changes and enhancements from the original:\n\n* The clipboard handling is simplified by the removal of the emacs-only kill ring (which was also an unfinished implementation in the original). Copy, Cut, Yank and C-K work with the system clipboard now.\n* C+x k to close tab, C+x C-k all tabs\n* C+l centers screen on the cursor line\n* C+x C+f bound to quick open file\n* yank overwrites selection\n\n\n### Move commands\n|Command | Desc |\n|--------|------|\n| `C-f` | Move forward |\n| `C-b` | Move backward |\n| `C-n` | Move to the next line |\n| `C-p` | Move to the previous line |\n| `C-a` | Move to the beginning of line |\n| `C-e` | Move to the end of line |\n| `M-f` | Move forward by one word unit |\n| `M-b` | Move backward by one word unit |\n| `M->` | Move to the end of buffer |\n| `M-<` | Move to the beginning of buffer |\n| `C-v` | Scroll down by one screen unit |\n| `M-v` | Scroll up by one screen unit |\n| `M-g g` | Jump to line (command palette) |\n| `M-g n` | Jump to next error |\n| `M-g p` | Jump to previous error |\n| `C-l` |  Center screen on current line |\n\n\n### Search Commands\n|Command | Desc |\n|--------|------|\n| `C-s` | Search forward |\n| `C-r` | Search backward |\n| `A-%` | Replace |\n| `C-Enter` | Replace One Match (In replace dialog) |\n| `C-M-n` | Add selection to next find match |\n\n\n### Edit commands\n|Command | Desc |\n|--------|------|\n| `C-d` | Delete right (DEL) |\n| `C-h` | Delete left (BACKSPACE) |\n| `M-d` | Delete word |\n| `M-Bksp` | Delete word left |\n| `C-k` | Kill to line end |\n| `C-S-Bksp` | Kill entire line |\n| `C-o` | open-line |\n| `C-w` | Kill region |\n| `M-w` | Copy region to kill ring |\n| `C-y` | Yank |\n| `C-j` | Enter |\n| `C-m` | Enter |\n| `C-x C-o` | Delete blank lines around |\n| `C-x h` | Select All |\n| `C-x u` (`C-/`, `C-_`)| Undo |\n| `C-;` | Toggle line comment in and out |\n| `M-;` | Toggle region comment in and out |\n| `C-x C-l` | Convert to lower case |\n| `C-x C-u` | Convert to upper case |\n\n### Other Commands\n|Command | Desc |\n|--------|------|\n| `C-g` | Cancel |\n| `C-space` | Set mark |\n| `C-quote` | IntelliSense Suggestion |\n| `M-x` | Open command palette |\n| `C-M-SPC` | Toggle SideBar visibility |\n| `C-x z` | | Toggle Zen Mode |\n| `C-x r` | | Open Recent |\n\n### File Commands\n|Command | Desc |\n|--------|------|\n| `C-x C-s` | Save |\n| `C-x C-w` | Save as |\n| `C-x C-n` | Open new window |\n\n### Tab / Buffer Manipulation Commands\n|Command | Desc |\n|--------|------|\n| `C-x b` | Switch to another open buffer |\n| `C-x C-f` | QuickOpen a file |\n| `C-x k` | Close current tab (buffer) |\n| `C-x C-k` | Close all tabs |\n| `C-x 0` | Close editors in the current group.  |\n| `C-x 1` | Close editors in other (split) group.  |\n| `C-x 2` | Split editor horizontal |\n| `C-x 3` | Split editor vertical |\n| `C-x 4` | Toggle split layout (vertical to horizontal) |\n| `C-x o` | Focus other split editor |\n\n## Conflicts with default key bindings\n- `ctrl+d`: editor.action.addSelectionToNextFindMatch => **Use `ctrl+alt+n` instead**;\n- `ctrl+g`: workbench.action.gotoLine => **Use `alt+g g` instead**;\n- `ctrl+b`: workbench.action.toggleSidebarVisibility => **Use `ctrl+alt+space` instead**;\n- `ctrl+space`: toggleSuggestionDetails, editor.action.triggerSuggest => **Use `ctrl+'` instead**;\n- `ctrl+x`: editor.action.clipboardCutAction => **Use `ctrl+w` instead**;\n- `ctrl+v`: editor.action.clipboardPasteAction => **Use `ctrl+y` instead**;\n- `ctrl+k`: editor.debug.action.showDebugHover, editor.action.trimTrailingWhitespace, editor.action.showHover, editor.action.removeCommentLine, editor.action.addCommentLine, editor.action.openDeclarationToTheSide;\n- `ctrl+k z`: workbench.action.toggleZenMode => **Use `ctrl+x z` instead**;\n- `ctrl+y`: redo;\n- `ctrl+m`: editor.action.toggleTabFocusMode;\n- `ctrl+/`: editor.action.commentLine => **Use `ctrl+;` instead**;\n- `ctrl+p` & `ctrl+e`: workbench.action.quickOpen => **Use `ctrl+x b` instead**;\n- `ctrl+p`: workbench.action.quickOpenNavigateNext => **Use `ctrl+n` instead**.\n- `ctrl+o`: workbench.action.files.openFile => **Use `ctrl+x ctrl+f` instead**.\n- `ctrl+r`: workbench.action.openRecent => **Use `ctrl+x r` instead**.\n\n# More information\n\nThe logo is from the great [Pacifica Icon Set](http://bokehlicia.deviantart.com/art/Pacifica-Icons-402508559).\n"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"vscode-emacs-friendly\",\n    \"displayName\": \"Emacs Friendly Keymap\",\n    \"description\": \"Emacs keybindings and selection, friendly interaction with the system clipboard.\",\n    \"icon\": \"emacs_pacifica.png\",\n    \"version\": \"0.9.0\",\n    \"publisher\": \"lfs\",\n    \"homepage\": \"https://github.com/SebastianZaha/vscode-emacs-friendly\",\n    \"repository\": {\n        \"type\": \"git\",\n        \"url\": \"https://github.com/SebastianZaha/vscode-emacs-friendly\"\n    },\n    \"bugs\": \"https://github.com/SebastianZaha/vscode-emacs-friendly/issues\",\n    \"engines\": {\n        \"vscode\": \"^1.30.0\"\n    },\n    \"categories\": [\n        \"Other\",\n        \"Keymaps\"\n    ],\n    \"keywords\": [\n        \"emacs\",\n        \"shortcuts\",\n        \"keybindings\",\n        \"behavior\",\n        \"selection\"\n    ],\n    \"activationEvents\": [\n        \"*\"\n    ],\n    \"main\": \"./out/src/extension\",\n    \"contributes\": {\n        \"keybindings\": [\n            {\n                \"key\": \"right\",\n                \"command\": \"emacs.cursorRight\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+f\",\n                \"command\": \"emacs.cursorRight\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+f\",\n                \"command\": \"emacs.cursorRight\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+f\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"left\",\n                \"command\": \"emacs.cursorLeft\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+b\",\n                \"command\": \"emacs.cursorLeft\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+b\",\n                \"command\": \"emacs.cursorLeft\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+b\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"up\",\n                \"command\": \"emacs.cursorUp\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"up\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"emacs.cursorUp\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"emacs.cursorUp\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"down\",\n                \"command\": \"emacs.cursorDown\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"down\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"emacs.cursorDown\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"emacs.cursorDown\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"home\",\n                \"command\": \"emacs.cursorHome\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+a\",\n                \"command\": \"emacs.cursorHome\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+a\",\n                \"command\": \"emacs.cursorHome\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+a\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"end\",\n                \"command\": \"emacs.cursorEnd\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+e\",\n                \"command\": \"emacs.cursorEnd\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+e\",\n                \"command\": \"emacs.cursorEnd\",\n                \"when\": \"terminalFocus\"\n            },\n            {\n                \"key\": \"ctrl+e\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+f\",\n                \"command\": \"emacs.cursorWordRight\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"alt+b\",\n                \"command\": \"emacs.cursorWordLeft\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"pagedown\",\n                \"command\": \"emacs.cursorPageDown\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"pagedown\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+v\",\n                \"command\": \"emacs.cursorPageDown\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+v\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"pageup\",\n                \"command\": \"emacs.cursorPageUp\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"pageup\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+v\",\n                \"command\": \"emacs.cursorPageUp\",\n                \"when\": \"editorTextFocus && !suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+v\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+shift+.\",\n                \"command\": \"emacs.cursorBottom\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"alt+shift+.\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+shift+,\",\n                \"command\": \"emacs.cursorTop\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"alt+shift+,\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+g g\",\n                \"command\": \"workbench.action.gotoLine\"\n            },\n            {\n                \"key\": \"alt+g n\",\n                \"command\": \"editor.action.marker.next\"\n            },\n            {\n                \"key\": \"alt+g p\",\n                \"command\": \"editor.action.marker.prev\"\n            },\n            {\n                \"key\": \"alt+g g\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+s\",\n                \"command\": \"actions.find\",\n                \"when\": \"!findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+shift+5\",\n                \"command\": \"editor.action.startFindReplaceAction\",\n                \"when\": \"editorFocus\"\n            },\n            {\n                \"command\": \"editor.action.replaceOne\",\n                \"key\": \"ctrl+enter\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+s\",\n                \"command\": \"actions.find\",\n                \"when\": \"textInputFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+s\",\n                \"command\": \"editor.action.nextMatchFindAction\",\n                \"when\": \"findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+r\",\n                \"command\": \"actions.find\",\n                \"when\": \"!findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+r\",\n                \"command\": \"actions.find\",\n                \"when\": \"textInputFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+r\",\n                \"command\": \"editor.action.previousMatchFindAction\",\n                \"when\": \"findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+alt+n\",\n                \"command\": \"editor.action.addSelectionToNextFindMatch\",\n                \"when\": \"editorFocus\"\n            },\n            {\n                \"key\": \"ctrl+d\",\n                \"command\": \"deleteRight\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+h\",\n                \"command\": \"deleteLeft\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"alt+d\",\n                \"command\": \"deleteWordRight\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+k\",\n                \"command\": \"emacs.C-k\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+w\",\n                \"command\": \"emacs.C-w\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+w\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+w\",\n                \"command\": \"emacs.M-w\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"alt+w\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+y\",\n                \"command\": \"emacs.C-y\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+y\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+m\",\n                \"command\": \"emacs.C-j\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+j\",\n                \"command\": \"emacs.C-j\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+j\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+o\",\n                \"command\": \"editor.action.insertLineBefore\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+o\",\n                \"command\": \"emacs.C-x_C-o\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+o\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+x h\",\n                \"command\": \"editor.action.selectAll\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+x h\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+x u\",\n                \"command\": \"emacs.C-/\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+x u\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+/\",\n                \"command\": \"emacs.C-/\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+/\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+shift+-\",\n                \"command\": \"emacs.C-/\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+_\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+x r\",\n                \"command\": \"workbench.action.openRecent\"\n            },\n\t\t\t{\n                \"key\": \"ctrl+x z\",\n                \"command\": \"workbench.action.toggleZenMode\"\n            },\n            {\n                \"key\": \"ctrl+;\",\n                \"command\": \"editor.action.commentLine\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+;\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"alt+;\",\n                \"command\": \"editor.action.blockComment\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"alt+;\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+l\",\n                \"command\": \"emacs.C-l\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"emacs.C-g\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeFindWidget\",\n                \"when\": \"editorFocus && findWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"emacs.exitMarkMode\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeReferenceSearchEditor\",\n                \"when\": \"inReferenceSearchEditor && !config.editor.stablePeek\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeReferenceSearch\",\n                \"when\": \"referenceSearchVisible && !config.editor.stablePeek\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeBreakpointWidget\",\n                \"when\": \"breakpointWidgetVisible && editorFocus\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"leaveSnippet\",\n                \"when\": \"editorTextFocus && inSnippetMode\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeMarkersNavigation\",\n                \"when\": \"editorFocus && markersNavigationVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeParameterHints\",\n                \"when\": \"editorTextFocus && parameterHintsVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"hideSuggestWidget\",\n                \"when\": \"editorTextFocus && suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"cancelRenameInput\",\n                \"when\": \"editorFocus && renameInputVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeAccessibilityHelp\",\n                \"when\": \"accessibilityHelpWidgetVisible && editorFocus\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"closeReplaceInFilesWidget\",\n                \"when\": \"replaceInputBoxFocus && searchViewletVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"workbench.action.closeMessages\",\n                \"when\": \"globalMessageVisible\"\n            },\n            {\n                \"key\": \"ctrl+g\",\n                \"command\": \"workbench.action.closeQuickOpen\",\n                \"when\": \"inQuickOpen\"\n            },\n            {\n                \"key\": \"ctrl+space\",\n                \"command\": \"emacs.enterMarkMode\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+f\",\n                \"command\": \"workbench.action.quickOpen\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+s\",\n                \"command\": \"workbench.action.files.save\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+w\",\n                \"command\": \"workbench.action.files.saveAs\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+x k\",\n                \"command\": \"workbench.action.closeActiveEditor\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl-k\",\n                \"command\": \"workbench.action.closeAllEditors\"\n            },\n            {\n                \"key\": \"ctrl+x k\",\n                \"command\": \"workbench.action.closeWindow\",\n                \"when\": \"!editorIsOpen\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+n\",\n                \"command\": \"workbench.action.newWindow\"\n            },\n            {\n                \"key\": \"ctrl+x 0\",\n                \"command\": \"workbench.action.closeEditorsInGroup\"\n            },\n            {\n                \"key\": \"ctrl+x 1\",\n                \"command\": \"workbench.action.closeEditorsInOtherGroups\"\n            },\n            {\n                \"key\": \"ctrl+x 2\",\n                \"command\": \"workbench.action.splitEditorDown\"\n            },\n            {\n                \"key\": \"ctrl+x 3\",\n                \"command\": \"workbench.action.splitEditorRight\"\n            },\n            {\n                \"key\": \"ctrl+x 4\",\n                \"command\": \"workbench.action.toggleEditorGroupLayout\"\n            },\n            {\n                \"key\": \"ctrl+x o\",\n                \"command\": \"workbench.action.navigateEditorGroups\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"showPrevParameterHint\",\n                \"when\": \"editorTextFocus && parameterHintsVisible\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"showNextParameterHint\",\n                \"when\": \"editorTextFocus && parameterHintsVisible\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"selectPrevQuickFix\",\n                \"when\": \"editorFocus && quickFixWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"selectNextQuickFix\",\n                \"when\": \"editorFocus && quickFixWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"selectPrevSuggestion\",\n                \"when\": \"editorTextFocus && suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"selectNextSuggestion\",\n                \"when\": \"editorTextFocus && suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+p\",\n                \"command\": \"workbench.action.quickOpenNavigatePrevious\",\n                \"when\": \"inQuickOpen\"\n            },\n            {\n                \"key\": \"ctrl+n\",\n                \"command\": \"workbench.action.quickOpenNavigateNext\",\n                \"when\": \"inQuickOpen\"\n            },\n            {\n                \"key\": \"ctrl+'\",\n                \"command\": \"editor.action.triggerSuggest\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+'\",\n                \"command\": \"toggleSuggestionDetails\",\n                \"when\": \"editorTextFocus && suggestWidgetVisible\"\n            },\n            {\n                \"key\": \"ctrl+shift+'\",\n                \"command\": \"editor.action.triggerParameterHints\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"alt+x\",\n                \"command\": \"workbench.action.showCommands\"\n            },\n            {\n                \"key\": \"ctrl+alt+space\",\n                \"command\": \"workbench.action.toggleSidebarVisibility\"\n            },\n            {\n                \"key\": \"ctrl+x b\",\n                \"command\": \"workbench.action.showAllEditors\"\n            },\n            {\n                \"key\": \"ctrl+shift+backspace\",\n                \"command\": \"emacs.C-S_bs\",\n                \"when\": \"editorTextFocus\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+l\",\n                \"command\": \"editor.action.transformToLowercase\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"ctrl+x ctrl+u\",\n                \"command\": \"editor.action.transformToUppercase\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            },\n            {\n                \"key\": \"alt+backspace\",\n                \"command\": \"deleteWordLeft\",\n                \"when\": \"editorTextFocus && !editorReadonly\"\n            }\n        ]\n    },\n    \"scripts\": {\n        \"vscode:prepublish\": \"tsc -p ./\",\n        \"compile\": \"tsc -watch -p ./\",\n        \"postinstall\": \"node ./node_modules/vscode/bin/install\",\n        \"lint\": \"tslint -p tslint.json --type-check **/*.ts\"\n    },\n    \"devDependencies\": {\n        \"@types/mocha\": \"^2.2.41\",\n        \"@types/node\": \"^6.0.81\",\n        \"mocha\": \"^6.1.4\",\n        \"typescript\": \"^2.4.1\",\n        \"vscode\": \"^1.1.34\"\n    },\n    \"dependencies\": {}\n}\n"
  },
  {
    "path": "src/editor.ts",
    "content": "import * as vscode from 'vscode';\n\n// Possible positions when C-l is invoked consequtively\nenum RecenterPosition {\n  Middle,\n  Top,\n  Bottom\n};\n\nexport class Editor {\n\tprivate lastKill: vscode.Position // if kill position stays the same, append to clipboard\n\tprivate justDidKill: boolean\n\tprivate centerState: RecenterPosition\n\n\tconstructor() {\n\t\tthis.justDidKill = false\n\t\tthis.lastKill = null\n\t\tthis.centerState = RecenterPosition.Middle\n\n\t\tvscode.window.onDidChangeActiveTextEditor(event => {\n\t\t\tthis.lastKill = null\n\t\t})\n\t\tvscode.workspace.onDidChangeTextDocument(event => {\n\t\t\tif (!this.justDidKill) {\n\t\t\t\tthis.lastKill = null\n\t\t\t}\n\t\t\tthis.justDidKill = false\n\t\t})\n\t\tvscode.window.onDidChangeTextEditorSelection(event => {\n\t\t\tthis.centerState = RecenterPosition.Middle\n\t\t})\n\t}\n\n\tstatic isOnLastLine(): boolean {\n\t\treturn vscode.window.activeTextEditor.selection.active.line == vscode.window.activeTextEditor.document.lineCount - 1\n\t}\n\n\tsetStatusBarMessage(text: string): vscode.Disposable {\n\t\treturn vscode.window.setStatusBarMessage(text, 1000);\n\t}\n\n\tsetStatusBarPermanentMessage(text: string): vscode.Disposable {\n\t\treturn vscode.window.setStatusBarMessage(text);\n\t}\n\n\tgetSelectionRange(): vscode.Range {\n\t\tlet selection = vscode.window.activeTextEditor.selection,\n\t\t\tstart = selection.start,\n\t\t\tend = selection.end;\n\n\t\treturn (start.character !== end.character || start.line !== end.line) ? new vscode.Range(start, end) : null;\n\t}\n\n\tgetSelection(): vscode.Selection {\n\t\treturn vscode.window.activeTextEditor.selection;\n\t}\n\n\tgetSelectionText(): string {\n\t\tlet r = this.getSelectionRange()\n\t\treturn r ? vscode.window.activeTextEditor.document.getText(r) : ''\n\t}\n\n\tsetSelection(start: vscode.Position, end: vscode.Position): void {\n\t\tlet editor = vscode.window.activeTextEditor;\n\t\teditor.selection = new vscode.Selection(start, end);\n\t}\n\n\tgetCurrentPos(): vscode.Position {\n\t\treturn vscode.window.activeTextEditor.selection.active\n\t}\n\n\t// Kill to end of line\n\tasync kill(): Promise<boolean> {\n\t\t// Ignore whatever we have selected before\n\t\tawait vscode.commands.executeCommand(\"emacs.exitMarkMode\")\n\n\t\tlet startPos = this.getCurrentPos(),\n\t\t\tisOnLastLine = Editor.isOnLastLine()\n\n\t\t// Move down an entire line (not just the wrapped part), and to the beginning.\n\t\tawait vscode.commands.executeCommand(\"cursorMove\", { to: \"down\", by: \"line\", select: false })\n\t\tif (!isOnLastLine) {\n\t\t\tawait vscode.commands.executeCommand(\"cursorMove\", { to: \"wrappedLineStart\" })\n\t\t}\n\n\t\tlet endPos = this.getCurrentPos(),\n\t\t\trange = new vscode.Range(startPos, endPos),\n\t\t\ttxt = vscode.window.activeTextEditor.document.getText(range)\n\n\t\t// If there is something other than whitespace in the selection, we do not cut the EOL too\n\t\tif (!isOnLastLine && !txt.match(/^\\s*$/)) {\n\t\t\tawait vscode.commands.executeCommand(\"cursorMove\", {to: \"left\", by: \"character\"})\n\t\t\tendPos = this.getCurrentPos()\n\t\t}\n\n\t\t// Select it now, cut the selection, remember the position in case of multiple cuts from same spot\n\t\tthis.setSelection(startPos, endPos)\n\t\tlet promise = this.cut(this.lastKill != null && startPos.isEqual(this.lastKill))\n\n\t\tpromise.then(() => {\n\t\t\tthis.justDidKill = true\n\t\t\tthis.lastKill = startPos\n\t\t})\n\n\t\treturn promise\n\t}\n\n\tcopy(): void {\n\t\tvscode.env.clipboard.writeText(this.getSelectionText())\n\t\tvscode.commands.executeCommand(\"emacs.exitMarkMode\")\n\t}\n\n\tasync cut(appendClipboard?: boolean): Promise<boolean> {\n\t\tif (appendClipboard) {\n\t\t\tconst text = await vscode.env.clipboard.readText();\n\t\t\tvscode.env.clipboard.writeText(text + this.getSelectionText())\n\t\t} else {\n\t\t\tvscode.env.clipboard.writeText(this.getSelectionText())\n\t\t}\n\t\tlet t = Editor.delete(this.getSelectionRange());\n\t\tvscode.commands.executeCommand(\"emacs.exitMarkMode\");\n\t\treturn t\n\t}\n\n\tyank(): Thenable<{}> {\n\t\tthis.justDidKill = false\n\t\treturn Promise.all([\n\t\t\tvscode.commands.executeCommand(\"editor.action.clipboardPasteAction\"),\n\t\t\tvscode.commands.executeCommand(\"emacs.exitMarkMode\")])\n\t}\n\n\tundo(): void {\n\t\tvscode.commands.executeCommand(\"undo\");\n\t}\n\n\tprivate getFirstBlankLine(range: vscode.Range): vscode.Range {\n\t\tlet doc = vscode.window.activeTextEditor.document;\n\n\t\tif (range.start.line === 0) {\n\t\t\treturn range;\n\t\t}\n\t\trange = doc.lineAt(range.start.line - 1).range;\n\t\twhile (range.start.line > 0 && range.isEmpty) {\n\t\t\trange = doc.lineAt(range.start.line - 1).range;\n\t\t}\n\t\tif (range.isEmpty) {\n\t\t\treturn range;\n\t\t} else {\n\t\t\treturn doc.lineAt(range.start.line + 1).range;\n\t\t}\n\t}\n\n\tasync deleteBlankLines() {\n\t\tlet selection = this.getSelection(),\n\t\t\tanchor = selection.anchor,\n\t\t\tdoc = vscode.window.activeTextEditor.document,\n\t\t\trange = doc.lineAt(selection.start.line).range,\n\t\t\tnextLine: vscode.Position;\n\n\t\tif (range.isEmpty) {\n\t\t\trange = this.getFirstBlankLine(range);\n\t\t\tanchor = range.start;\n\t\t\tnextLine = range.start;\n\t\t} else {\n\t\t\tnextLine = range.start.translate(1, 0);\n\t\t}\n\t\tselection = new vscode.Selection(nextLine, nextLine);\n\t\tvscode.window.activeTextEditor.selection = selection;\n\n\t\tfor (let line = selection.start.line;\n\t\t\t\tline < doc.lineCount - 1  && doc.lineAt(line).range.isEmpty;\n\t\t    \t++line) {\n\n\t\t\tawait vscode.commands.executeCommand(\"deleteRight\")\n\t\t}\n\t\tvscode.window.activeTextEditor.selection = new vscode.Selection(anchor, anchor)\n\t}\n\n\tstatic delete(range: vscode.Range = null): Thenable<boolean> {\n\t\tif (range) {\n\t\t\treturn vscode.window.activeTextEditor.edit(editBuilder => {\n\t\t\t\teditBuilder.delete(range);\n\t\t\t});\n\t\t}\n\t}\n\n\tdeleteLine() : void {\n\t\tvscode.commands.executeCommand(\"emacs.exitMarkMode\"); // emulate Emacs\n\t\tvscode.commands.executeCommand(\"editor.action.deleteLines\");\n\t}\n\n\tscrollLineToCenterTopBottom = () => {\n\t\tconst editor = vscode.window.activeTextEditor\n\t\tconst selection = editor.selection\n\n\t\tswitch (this.centerState) {\n\t\t\tcase RecenterPosition.Middle:\n\t\t\t\tthis.centerState = RecenterPosition.Top;\n\t\t\t\teditor.revealRange(selection, vscode.TextEditorRevealType.InCenter);\n\t\t\t\tbreak;\n\t\t\tcase RecenterPosition.Top:\n\t\t\t\tthis.centerState = RecenterPosition.Bottom;\n\t\t\t\teditor.revealRange(selection, vscode.TextEditorRevealType.AtTop);\n\t\t\t\tbreak;\n\t\t\tcase RecenterPosition.Bottom:\n\t\t\t\tthis.centerState = RecenterPosition.Middle;\n\t\t\t\t// There is no AtBottom, so instead scroll a page up (without moving cursor).\n\t\t\t\t// The current line then ends up as the last line of the window (more or less)\n\t\t\t\tvscode.commands.executeCommand(\"scrollPageUp\");\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tbreakLine() {\n\t\tvscode.commands.executeCommand(\"lineBreakInsert\");\n\t\tvscode.commands.executeCommand(\"emacs.cursorHome\");\n\t\tvscode.commands.executeCommand(\"emacs.cursorDown\");\n\t}\n}\n"
  },
  {
    "path": "src/extension.ts",
    "content": "import * as vscode from 'vscode';\nimport {Operation} from './operation';\n\nvar inMarkMode: boolean = false;\nvar markHasMoved: boolean = false;\nexport function activate(context: vscode.ExtensionContext): void {\n    let op = new Operation(),\n        commandList: string[] = [\n            \"C-g\",\n\n            // Edit\n            \"C-k\", \"C-w\", \"M-w\", \"C-y\", \"C-x_C-o\",\n            \"C-/\", \"C-j\", \"C-S_bs\",\n\n            // Navigation\n            \"C-l\",\n        ],\n        cursorMoves: string[] = [\n            \"cursorUp\", \"cursorDown\", \"cursorLeft\", \"cursorRight\",\n            \"cursorHome\", \"cursorEnd\",\n            \"cursorWordLeft\", \"cursorWordRight\",\n            \"cursorPageDown\", \"cursorPageUp\",\n            \"cursorTop\", \"cursorBottom\"\n        ];\n\n    commandList.forEach(commandName => {\n        context.subscriptions.push(registerCommand(commandName, op));\n    });\n\n    cursorMoves.forEach(element => {\n        context.subscriptions.push(vscode.commands.registerCommand(\n            \"emacs.\"+element, () => {\n                if (inMarkMode) {\n                    markHasMoved  = true;\n                }\n                vscode.commands.executeCommand(\n                    inMarkMode ?\n                    element+\"Select\" :\n                    element\n                );\n            })\n        )\n    });\n\n    initMarkMode(context);\n}\n\nexport function deactivate(): void {\n}\n\nfunction initMarkMode(context: vscode.ExtensionContext): void {\n    context.subscriptions.push(vscode.commands.registerCommand(\n        'emacs.enterMarkMode', () => {\n            if (inMarkMode && !markHasMoved) {\n                inMarkMode = false;\n            } else {\n                initSelection();\n                inMarkMode = true;\n                markHasMoved = false;\n            }\n        })\n    );\n\n    context.subscriptions.push(vscode.commands.registerCommand(\n        'emacs.exitMarkMode', () => {\n            const selections = vscode.window.activeTextEditor.selections;\n            const hasMultipleSelecitons = selections.length > 1;\n            if (hasMultipleSelecitons) {\n                const allSelectionsAreEmpty = selections.every(selection => selection.isEmpty);\n                if (allSelectionsAreEmpty) {\n                    vscode.commands.executeCommand(\"removeSecondaryCursors\");\n                } else {\n                    // initSelection() is used here instead of `executeCommand(\"cancelSelection\")`\n                    // because `cancelSelection` command not only cancels selection state\n                    // but also removes secondary cursors though these should remain in this case.\n                    initSelection();\n                }\n            } else {\n                // This `executeCommand(\"cancelSelection\")` may be able to be replaced with `initSelection()`,\n                // however, the core command is used here to follow its updates with ease.\n                vscode.commands.executeCommand(\"cancelSelection\");\n            }\n\n            if (inMarkMode) {\n                inMarkMode = false;\n            }\n        })\n    );\n}\n\nfunction registerCommand(commandName: string, op: Operation): vscode.Disposable {\n    return vscode.commands.registerCommand(\"emacs.\" + commandName, op.getCommand(commandName));\n}\n\nfunction initSelection(): void {\n    // Set new `anchor` and `active` values to all selections so that these are initialized to be empty.\n    vscode.window.activeTextEditor.selections = vscode.window.activeTextEditor.selections.map(selection => {\n        const currentPosition: vscode.Position = selection.active;\n        return new vscode.Selection(currentPosition, currentPosition);\n    });\n}\n"
  },
  {
    "path": "src/operation.ts",
    "content": "import {Editor} from './editor';\n\nexport class Operation {\n    private editor: Editor;\n    private commandList: { [key: string]: (...args: any[]) => any, thisArgs?: any } = {};\n\n    constructor() {\n        this.editor = new Editor();\n        this.commandList = {\n            'C-k': () => {\n                this.editor.kill();\n            },\n            'C-w': () => {\n                this.editor.cut()\n            },\n            'M-w': () => {\n                this.editor.copy()\n            },\n            'C-y': () => {\n                this.editor.yank()\n            },\n            \"C-x_C-o\": () => {\n                this.editor.deleteBlankLines();\n            },\n            \"C-/\": () => {\n                this.editor.undo();\n                this.editor.setStatusBarMessage(\"Undo!\");\n            },\n            'C-j': () => {\n                this.editor.breakLine();\n            },\n            'C-g': () => {\n                this.editor.setStatusBarMessage(\"Quit\");\n            },\n            \"C-S_bs\": () => {\n                this.editor.deleteLine();\n            },\n            'C-l': () => {\n                this.editor.scrollLineToCenterTopBottom()\n            }\n        };\n    }\n\n    getCommand(commandName: string): (...args: any[]) => any {\n        return this.commandList[commandName];\n    }\n}\n"
  },
  {
    "path": "test/c-k.test.ts",
    "content": "import * as assert from 'assert'\nimport * as vscode from 'vscode'\n\nimport * as utils from './utils'\nimport {Editor} from '../src/editor'\n\nsuite(\"C-K functionality\", () => {\n\n    test(\"EOL behavior\", async () => {\n\n        let c = \"line 1\\nline 2\\nline 3\\n\",\n            e = new Editor()\n\n        let doc = await vscode.workspace.openTextDocument({content: c, language: 'text'})\n        await vscode.window.showTextDocument(doc)\n\n        await e.kill()\n        await e.kill()\n        await e.kill()\n        assert.equal(doc.getText(), \"\\nline 3\\n\")\n        await e.yank()\n        assert.equal(doc.getText(), c)\n\n        await utils.moveCursorToBeginning()\n        \n        await e.kill()\n        assert.equal(doc.getText(), \"\\nline 2\\nline 3\\n\")\n        await e.yank()\n        assert.equal(doc.getText(), c)\n        \n        await utils.moveCursorToBeginning()\n\n        await e.kill()\n        await e.kill()\n        assert.equal(doc.getText(), \"line 2\\nline 3\\n\")\n        await e.yank()\n        assert.equal(doc.getText(), c)\n\n        await utils.moveCursorToBeginning()\n\n        await e.kill()\n        await e.kill()\n        await e.kill()\n        await e.kill()\n        assert.equal(doc.getText(), \"line 3\\n\")\n        await e.yank()\n        assert.equal(doc.getText(), c)\n    });\n});\n"
  },
  {
    "path": "test/index.ts",
    "content": "//\n// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING\n//\n// This file is providing the test runner to use when running extension tests.\n// By default the test runner in use is Mocha based.\n//\n// You can provide your own test runner if you want to override it by exporting\n// a function run(testRoot: string, clb: (error:Error) => void) that the extension\n// host can call to run the tests. The test runner is expected to use console.log\n// to report the results back to the caller. When the tests are finished, return\n// a possible error to the callback or null if none.\n\nvar testRunner = require('vscode/lib/testrunner');\n\n// You can directly control Mocha options by uncommenting the following lines\n// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info\ntestRunner.configure({\n    ui: 'tdd', \t\t// the TDD UI is being used in extension.test.ts (suite, test, etc.)\n    useColors: true // colored output from test results\n});\n\nmodule.exports = testRunner;"
  },
  {
    "path": "test/utils.ts",
    "content": "import * as vscode from 'vscode'\n\nexport function moveCursorToBeginning(): Thenable<{}> {\n    vscode.commands.executeCommand(\"cursorMove\", {to: \"wrappedLineStart\", select: false})\n    return vscode.commands.executeCommand(\"cursorMove\", {to: \"up\", by: \"line\", select: false, value: Number.MAX_VALUE})\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"module\": \"commonjs\",\n        \"target\": \"es6\",\n        \"outDir\": \"out\",\n        \"lib\": [\n            \"es6\",\n            \"esnext.asynciterable\"\n        ],\n        \"sourceMap\": true,\n        \"rootDir\": \".\",\n\t\t\"noUnusedLocals\": true\n    },\n    \"exclude\": [\n        \"node_modules\",\n        \".vscode-test\"\n    ]\n}\n"
  },
  {
    "path": "tslint.json",
    "content": "{\n\t\"rules\": {\n\t\t\"no-unused-expression\": true,\n\t\t\"no-duplicate-variable\": true,\n\t\t\"no-unused-variable\": true,\n\t\t\"curly\": false,\n\t\t\"class-name\": true,\n\t\t\"semicolon\": [\"never\"],\n\t\t\"triple-equals\": false\n\t}\n}"
  }
]