Sublime-text 3 Vintage Mode mapping - vim

Please help with mapping in VintageMode.
I want to avoid Esc key
http://vim.wikia.com/wiki/Avoid_the_escape_key
ho to map these keys?
Alt+o opens a new line below the one you are currently editing,
Alt+A appends to the end of the current line,
Alt+p pastes at the current insert location.
Alt+k moves up

You can open the Default keymap and copy the entries you want to have into your User keymap. Afterwards prefix the keybinding with alt+ and if it is uppercase alt+shift+ and the lowercase char. Change the context from "key": "setting.command_mode" to "key": "setting.command_mode", "operator": "equal", "operand": false. Do this for every keybinding you want and it should work.
Example:
{ "keys": ["alt+shift+a"], "command": "enter_insert_mode", "args":
{"insert_command": "move_to", "insert_args": {"to": "hardeol"} },
"context": [{"key": "setting.command_mode", "operator": "equal", "operand": false}]
},

To create custom Key Bindings use Menu > Preferences > Key Bindings, see Sublime Text Unofficial Documentation for detailed information on key Bindings.
Here is some documentation on customising Vintage.
To see the Vintage default Key Bindings, take a look at the Vintage package bundled with Sublime Text. Though out-of-date, the sublimehq has a Vintage package on github.
Also try Vintageous.

Related

User key bindings in Sublime Text 3 doesn't work

I'd like to customize some of the Sublime Text 3 keybindings to mimic IntelliJ IDEA. One of them is opening a file from the current project, also known as Goto Anything in Sublime jargaon. I followed the instructions in this answer to find out that the default key binding for "Goto Anything" is ⌘ + p on a Mac, like so:
{ "keys": ["super+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }
I added a new keybinding as follows:
[
{ "keys": ["shift+shift"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }
]
It, however, doesn't work; pressing shift twice in rapid succession does precisely nothing. When I open the console, I see the following message:
Unable to open /Users/me/Library/Application Support/Sublime Text
3/Packages/Default/Default (OSX).sublime-keymap
According to this ticket, this message is harmless but misleading, and is just an indication that Sublime is opening a file.
What's wrong then?
OP here; I found this post in Sublime blog.
ST doesn't support using only modifier keys in a keybinding.

Conflict with sublime hotkey

I am working with the sublime 3 text editor. I am modifying the User version of the keymap, however, it does not seem to be replacing the default keymap hotkeys. Specifically, in the Default keymap, I see the following assigned for the "copy" hotkey:
{ "keys": ["ctrl+insert"], "command": "copy" },
{ "keys": ["ctrl+c"], "command": "copy" },
There are two hotkeys assigned for the copy command, and I am not sure why. I use the latter command in my User keymap, but the hotkey is not working. The ctrl+insert hotkey is the one that is taking precedence.
Is there a way to modify the Default keymap for Sublime?
I don't see this conflict. But if you do, you can set a hotkey command to none if you don't want it to use.
{
"keys": ["ctrl+insert"],
"command": "none"
},

In VSCode, Exit Vim Insert Mode on Save

I use VSCode with the VSCodeVim extension. When in Insert Mode, I can press "CMD-S" to save. When I do, I would also like to exit Insert Mode automatically instead of pressing "ESC" as well.
Is this possible?
I was looking for a solution similar to this issue as well.
It appears that multiple commands cannot be mapped to key bindings in vscode; however, I've found an extension, macros, that let's you do this.
If you use the below steps with the macros extension, I believe that you'll have the solution you're looking for, until vscode implements something to address this feature request.
Step one, edit user settings with the below:
"macros": {
"saveAndExitVimInsertMode": [
"workbench.action.files.save",
"extension.vim_escape"
]
}
Step two, edit keyboard bindings:
{
"key": "cmd+s",
"command": "macros.saveAndExitVimInsertMode"
}
VSCodeVim extension supports insert mode key bindings. Here is a link to the extension readme that describes this feature.
Here is a snippet you could put in your settings.json.
"vim.insertModeKeyBindingsNonRecursive": [
{
"before": [ "<C-s>" ],
"commands": [
{ "command": "workbench.action.files.save" },
{ "command": "extension.vim_escape" }
]
}
],
After reloading your vscode window you can pressing ctrl+s to exit insert mode and save the file.
open Show Command Palette (Ctrl+Shift+P). enter 'open keyboard shortcut' ,
search 'extension.vim_escape' and edit it to be 2 times caps lock key.

Visual Studio Code pane management like Origami

Has anyone found a way to have more complex pane layouts in Visual Studio Code, like those supported by Origami for Sublime? Layouts beyond splitting on the same axis are something that I really miss from Sublime.
like #pat-putnam says, VSCode now supports editor window splitting 🎉
To replicate the Origami experience, we need the Origami keyboard shortcuts too. To do this, paste the JSON snippet shown below into your VSCode keybindings.json.
You can quickly open keybindings.json in VSCode by pressing cmd+shift+p and then typing keyb and clicking the Preferences: Open Keyboard Shortcuts (JSON) completion hint that appears.
[
{
"key": "cmd+k up",
"command": "workbench.action.splitEditorUp"
},
{
"key": "cmd+k right",
"command": "workbench.action.splitEditorRight"
},
{
"key": "cmd+k down",
"command": "workbench.action.splitEditorDown"
},
{
"key": "cmd+k left",
"command": "workbench.action.splitEditorLeft"
},
{
"key": "cmd+k up",
"command": "-workbench.action.moveActiveEditorGroupUp"
},
{
"key": "cmd+k right",
"command": "-workbench.action.moveActiveEditorGroupRight"
},
{
"key": "cmd+k down",
"command": "-workbench.action.moveActiveEditorGroupDown"
},
{
"key": "cmd+k left",
"command": "-workbench.action.moveActiveEditorGroupLeft"
}
]
Note that if you have existing key bindings that you want to preserve, you should remove the [ and ] from the JSON snippet and just paste the config objects into your existing array.
These custom keybindings are for the editor-window-splitting functionality from Origami that I use most often. There are a few more Origami keyboard shortcuts beyond these four. It would be cool in the future to create a VSCode keybinding file that fully replicated the Origami keyboard shortcuts, and then release that as a VSCode keymap. Future work.
I recently revisited Visual Studio Code and found that you can now window split to your hearts content. Simply right click on any pane and select the appropriate split action.

How to change keymap to add selection caret on Sublime Text?

How can I change the keymap to add selection caret on Sublime Text?
The default is ctrl + left mouse, I want to change to alt + left mouse, like PhpStorm's keymap.
In Sublime Text, sublime-keymap files are used for keyboard shortcuts and sublime-mousemap files for mouse actions. Your question is obviously about mouse shortcuts, but there are also some keyboard-related commands to add carets, so I will also talk about them.
Mousemap
Open your User mousemap at
Packages/User/Default (Linux/Windows).sublime-mousemap (*)
Add the entry:
{
"button": "button1", "modifiers": ["alt"],
"press_command": "drag_select",
"press_args": {"additive": true}
},
Change the button and modifiers for more tuning.
You can also use the lines and columns variants:
"press_args": {"by": "lines", "additive": true}
"press_args": {"by": "columns", "additive": true}
to select whole lines, or by columns. If you click without dragging in column selection, a caret will simply be added, so you can setup the columns variant, and only use the column selection when you need.
For more examples and variants, have a look at the default mousemap at
Packages/Default/Default (Linux/Windows).sublime-mousemap
(*) To access it directly from Sublime Text you can use the plugin PackageResourceViewer
If you prefer your own commands/shortcuts, create a entry in some sublime-commands file:
{
"caption": "Preferences: Mouse Bindings - Default",
"command": "open_file", "args":
{
"file": "${packages}/Default/Default ($platform).sublime-mousemap",
"contents": "[\n\t$0\n]\n" // start with "[]" if new file is created
}
}
and an entry in your keymap file (pick the shortcut you want)
{ "keys": ["super+alt+m"], "command": "open_file", "args": {"file": "${packages}/User/Default ($platform).sublime-mousemap", "contents": "[\n\t$0\n]\n"} }
Keymap
Apart from the caret duplication that happens when you select multiple occurences, there are commands to duplicate the caret on the lines above or below.
Open your User keymap file and add the entries:
{ "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },
with the shortcuts you want.
Caveats
In Sublime Text, there may be multiple shortcuts per command and adding a User shortcut does not deactivate Default shortcuts. If you want to deactivate some annoying default mouse behaviors, for example, you will have to:
copy the Default mousemap from your unzipped Default package (PackageResourceViewer does not seem to be able to extract it, so do it manually, by adding .zip to the sublime-package if required)
paste it to your Default package folder
uncomment the entries you want to ignore

Resources