├── init.lua ├── xclip ├── LICENSE ├── keymap.map ├── bindings.json └── README.md /init.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/zyedidia/micro/issues/1806 2 | function toggleSoftwrap(bp) 3 | bp.Buf.Settings["softwrap"] = not bp.Buf.Settings["softwrap"] 4 | end 5 | -------------------------------------------------------------------------------- /xclip: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | fake_bufferfile=/tmp/fake_xclip_buffer 4 | 5 | if [[ $1 == "-in" ]]; then 6 | cat - > "$fake_bufferfile" 7 | else 8 | cat "$fake_bufferfile" 9 | fi 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Philip Waritschlager 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /keymap.map: -------------------------------------------------------------------------------- 1 | # ctrl left 2 | control keycode 105 = F200 3 | string F200 = "\033[1;5D" 4 | 5 | # ctrl right 6 | control keycode 106 = F201 7 | string F201 = "\033[1;5C" 8 | 9 | # shift left 10 | shift keycode 105 = F202 11 | string F202 = "\033[1;2D" 12 | 13 | # shift right 14 | shift keycode 106 = F203 15 | string F203 = "\033[1;2C" 16 | 17 | # ctrl shift left 18 | control shift keycode 105 = F204 19 | string F204 = "\033[1;6D" 20 | 21 | # ctrl shift right 22 | control shift keycode 106 = F205 23 | string F205 = "\033[1;6C" 24 | 25 | # ctrl up 26 | control keycode 103 = F206 27 | string F206 = "\033[1;5A" 28 | 29 | # ctrl down 30 | control keycode 108 = F207 31 | string F207 = "\033[1;5B" 32 | 33 | # shift up 34 | shift keycode 103 = F208 35 | string F208 = "\033[1;2A" 36 | 37 | # shift down 38 | shift keycode 108 = F209 39 | string F209 = "\033[1;2B" 40 | 41 | # ctrl shift up 42 | control shift keycode 103 = F210 43 | string F210 = "\033[1;6A" 44 | 45 | # ctrl shift down 46 | control shift keycode 108 = F211 47 | string F211 = "\033[1;6B" 48 | 49 | # shift pgup 50 | shift keycode 104 = F212 51 | string F212 = "\033[5;2~" 52 | 53 | # shift pgdown 54 | shift keycode 109 = F213 55 | string F213 = "\033[6;2~" 56 | 57 | # ctrl home 58 | control keycode 102 = F214 59 | string F214 = "\033[1;5H" 60 | 61 | # ctrl end 62 | control keycode 107 = F215 63 | string F215 = "\033[1;5F" 64 | 65 | # shift home 66 | shift keycode 102 = F216 67 | string F216 = "\033[1;2H" 68 | 69 | # shift end 70 | shift keycode 107 = F217 71 | string F217 = "\033[1;2F" 72 | 73 | # ctrl shift home 74 | control shift keycode 102 = F218 75 | string F218 = "\033[1;6H" 76 | 77 | # ctrl shift end 78 | control shift keycode 107 = F219 79 | string F219 = "\033[1;6F" 80 | 81 | # shift tab 82 | shift keycode 15 = F220 83 | string F220 = "\033[Z" 84 | 85 | # Alt+up/down 86 | alt keycode 103 = F224 87 | string F224 = "\033[1;3A" 88 | alt keycode 108 = F225 89 | string F225 = "\033[1;3B" 90 | 91 | # shift delete 92 | shift keycode 111 = F231 93 | string F231 = "\033[3;2~" 94 | 95 | # ctrl delete 96 | control keycode 111 = F233 97 | string F233 = "\033[3;5~" 98 | 99 | # ctrl shift k 100 | control shift keycode 37 = F232 101 | string F232 = "\033[107;6u" 102 | 103 | # ctrl bs 104 | control keycode 14 = Control_h 105 | 106 | # f3 107 | keycode 61 = F3 108 | 109 | # shift f3 110 | shift keycode 61 = F234 111 | string F234 = "\033[1;2R" 112 | 113 | # ctrl shift alt down 114 | shift control alt keycode 108 = F235 115 | string F235 = "\033[1;8B" 116 | 117 | # ctrl pagedown 118 | control keycode 109 = F236 119 | string F236 = "\033[6;5~" 120 | 121 | # ctrl pageup 122 | control keycode 104 = F237 123 | string F237 = "\033[5;5~" 124 | 125 | # ctrl shift p 126 | control shift keycode 25 = F238 127 | string F238 = "\033[112;6u" 128 | 129 | # ctrl shift s 130 | control shift keycode 31 = F239 131 | string F239 = "\033[115;6u" 132 | -------------------------------------------------------------------------------- /bindings.json: -------------------------------------------------------------------------------- 1 | { 2 | /////// Basic navigation /////// 3 | // These bindings are also present in all Windows Notepad-like textinputs, e.g. HTML textarea, often referred to as Common User Access (CUA) 4 | 5 | "CtrlUp": "ScrollUp", 6 | "CtrlDown": "ScrollDown", 7 | "CtrlLeft": "WordLeft", 8 | "CtrlRight": "WordRight", 9 | "CtrlShiftEnd": "SelectToEnd", 10 | "CtrlShiftHome": "SelectToStart", 11 | "CtrlShiftLeft": "SelectWordLeft", 12 | "CtrlShiftRight": "SelectWordRight", 13 | "ShiftPageDown": "SelectPageDown", 14 | "ShiftPageUp": "SelectPageUp", 15 | 16 | /////// Visual Studio Code-specific keybindings /////// 17 | 18 | // expandLineSelection 19 | "Ctrl-l": "SelectLine", 20 | 21 | // editor.action.jumpToBracket 22 | "CtrlShiftBackspace": "JumpToMatchingBrace", 23 | 24 | // editor.action.addSelectionToNextFindMatch 25 | "Ctrl-d": "SpawnMultiCursor", 26 | // cursorUndo 27 | "Ctrl-u": "RemoveMultiCursor", 28 | // editor.action.moveSelectionToNextFindMatch 29 | "": "SkipMultiCursor", 30 | // cancelSelection 31 | "ShiftEscape": "RemoveAllMultiCursors", 32 | // editor.action.insertCursorBelow 33 | "CtrlShiftDown": "SpawnMultiCursorDown", 34 | // editor.action.insertCursorAgove 35 | "CtrlShiftUp": "SpawnMultiCursorUp", 36 | 37 | // editor.action.nextMatchFindAction 38 | "F3": "FindNext", 39 | // editor.action.previousMatchFindAction 40 | "ShiftF3": "FindPrevious", 41 | 42 | // workbench.action.gotoLine 43 | "Ctrl-g": "command-edit:goto ", 44 | 45 | // Move autocompletion from tab to ctrl+space 46 | "Tab": "IndentSelection|InsertTab", 47 | "CtrlSpace": "Autocomplete", 48 | 49 | // Need init.lua for this action. 50 | // editor.action.toggleWordWrap 51 | "Alt-z": "lua:initlua.toggleSoftwrap", 52 | 53 | // The bindings from the next block are often overwritten by the terminal emulator itself. 54 | // workbench.action.files.newUntitledFile 55 | "Ctrl-n": "AddTab", 56 | // workbench.action.nextEditor 57 | "CtrlPageDown": "NextTab", 58 | // workbench.action.previousEditor 59 | "CtrlPageUp": "PreviousTab", 60 | // workbench.action.closeWindow 61 | "Ctrl-w": "Quit", 62 | // workbench.action.quit 63 | "Ctrl-q": "QuitAll", 64 | // workbench.action.showCommands 65 | // "CtrlShiftP" 66 | "\u001b[112;6u": "CommandMode", 67 | 68 | // workbench.action.files.saveAs 69 | // "CtrlShift-s" 70 | "\u001b[115;6u": "SaveAs", 71 | 72 | // Function comes from a (default enabled) plugin. 73 | // editor.action.commentLine 74 | "Ctrl-/": "lua:comment.comment", 75 | 76 | // editor.action.deleteLines 77 | // "CtrlShift-k" 78 | "\u001b[107;6u": "DeleteLine", 79 | // Not documented in vscode but de facto keybinding shift+del (?) 80 | // editor.action.clipboardCutAction 81 | "ShiftDelete": "CutLine", 82 | // deleteWordLeft 83 | "CtrlBackspace": "DeleteWordLeft", 84 | "OldBackspace": "DeleteWordLeft", 85 | // deleteWordRight 86 | "CtrlDelete": "DeleteWordRight", 87 | 88 | // editor.action.copyLinesDownAction 89 | "CtrlShiftAltDown": "DuplicateLine" 90 | } 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code-like Keybindings for [micro editor](https://github.com/zyedidia/micro) 2 | 3 | ## What 4 | 5 | Based on Windows/Linux shortcuts, e.g. ctrlleft for WordLeft and so on, also sometimes referred to as Common User Access (CUA) 6 | 7 | Sets all available micro keybindings to their vscode counterpart default shortcuts, if present. 8 | 9 | ## Why 10 | 11 | With this setup, you can now use a powerful text editor (multi cursor, tabs, macros etc.) with keybindings you are familiar with, not having to learn new syntax. 12 | 13 | Maybe consider this README as a basic guide to moving from VSCode to Linux Terminal editor-wise for a more distraction-free and minimalist way of coding. Check out [ei2030's PaperTerm project](https://forum.ei2030.org/t/paperterm-project-definition-and-marketing-materials/146) if you're also interested in the hardware aspect of this. 14 | 15 | ## How 16 | 17 | Put `bindings.json` into the config dir (see [micro keybindings docs](https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md)). If you use the altz shortcut (toggle softwrap), you also need `init.lua` in this directory. 18 | 19 | These bindings are tailored to an English keyboard. Adjustments for other keyboard layouts should be minimal. 20 | 21 | ### TTY 22 | If you want to use these shortcuts in Linux virtual console (typically tty1-6), you also 23 | - need `sudo loadkeys /path/to/keymap.map`, for example in your `.bashrc`. This is explained [here](https://github.com/zyedidia/micro/wiki/Linux-Console-Keybindings). 24 | - might need to set micro config `xterm` to `true` if bindings like ctrlleft don't work 25 | - in case you didn't know, you can easily change tty [fonts](https://wiki.archlinux.org/index.php/Linux_console#Fonts) and [colors](http://archive.is/QSYHd) or change the terminal emulator, most commonly to 26 | - [KMSCON](https://wiki.archlinux.org/index.php/KMSCON) or 27 | - [fbterm](https://packages.debian.org/sid/utils/fbterm) (for Arch Linux, [this](https://github.com/glitsj16/fbterm-patched)+[this](https://gist.github.com/zellio/5809852) works well) 28 | - micro has a backup mechanic, but no session / restore functionality, it seems. For that, you will need a wrapper, for example tmux with [tmux-resurrect](https://github.com/tmux-plugins/tmux-resurrect). 29 | - without X11, there is no system clipboard. You need to use micro's internal clipboard. This fails for copying accross multiple opened micro processes. As a workaround, you can set up a clipboard manager yourself: Copy the file `xclip` to `/some/path`, make it executable and inject this fake xclip into the PATH when running micro, for example with an alias in your bashrc: `alias micro='PATH=/some/path:"$PATH" \micro'` 30 | 31 | ## Omitted keybindings 32 | 33 | The following actions are not included in `bindings.json` because they either don't exist in vscode or have no default keybinding there. Some of these are useful though. 34 | - FindLiteral (micro ctrlf is mapped to regex find) 35 | - HalfPageUp 36 | - HalfPageDown 37 | - ParagraphPrevious 38 | - ParagraphNext 39 | - ToggleHelp 40 | - ToggleDiffGutter 41 | - ToggleRuler 42 | - NextSplit 43 | - Unsplit 44 | - VSplit (micro split works great but you [cannot resize them by keyboad yet](https://github.com/zyedidia/micro/issues/1807), only mouse) 45 | - HSplit 46 | - PreviousSplit 47 | - ToggleMacro 48 | - PlayMacro 49 | - Anything from [plugins](https://raw.githubusercontent.com/micro-editor/plugin-channel/master/channel.json) 50 | --------------------------------------------------------------------------------