Skip to content

Instantly share code, notes, and snippets.

@diogotito
Last active June 25, 2024 14:33
Show Gist options
  • Save diogotito/8e36eef5d32e26cc40c0052687ae1a55 to your computer and use it in GitHub Desktop.
Save diogotito/8e36eef5d32e26cc40c0052687ae1a55 to your computer and use it in GitHub Desktop.
Sublime LiteVintageous
[
// -------------------------------------------------------------------------------------------
// Text editing tweaks
{ "keys": ["alt+j"], "command": "swap_line_down"},
{ "keys": ["alt+k"], "command": "swap_line_up"},
// * Emacs-like paragraph selection
{ "keys": ["alt+h"], "command": "expand_selection_to_paragraph", "args": {"markup_aware": true}},
{ "keys": ["alt+shift+h"], "command": "expand_selection_to_paragraph", "args": {"markup_aware": true}},
// * Bookmarks
{ "keys": ["ctrl+alt+shift+h"], "command": "prev_bookmark" },
{ "keys": ["ctrl+alt+shift+l"], "command": "next_bookmark" },
{ "keys": ["ctrl+alt+shift+k"], "command": "toggle_bookmark", "args": {"toggle_line": true } },
// -------------------------------------------------------------------------------------------
// View (tabs) navigation
{ "keys": ["g", "t"], "command": "next_view", "context": [{"key": "setting.command_mode"}] },
{ "keys": ["g", "T"], "command": "prev_view", "context": [{"key": "setting.command_mode"}] },
{ "keys": ["ctrl+alt+h"], "command": "prev_view" },
{ "keys": ["ctrl+alt+l"], "command": "next_view" },
{ "keys": ["tab"], "command": "next_view_in_stack", "context": [
{ "key": "setting.command_mode"},
{ "key": "setting.is_widget", "operand": false },
{ "key": "auto_complete_visible", "operand": false }] },
// -------------------------------------------------------------------------------------------
// Emacs minibuffer keybinding for Sublime Text command pallete
{ "keys": ["alt+x"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
// -------------------------------------------------------------------------------------------
// Vim tweaks (Vintage)
// * ZQ to close
{ "keys": ["Z", "Q"], "command": "close", "context": [{"key": "setting.command_mode"}]},
// * `jk` as <Esc>
{ "keys": ["j", "k"], "command": "exit_insert_mode",
"context": [
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
// make "ip" (inner paragraph) text object act like Sublime's "Selection: Expand to Paragraph"
{ "keys": ["i", "p"], "command": "set_motion", "args": {
"motion": "expand_selection_to_paragraph"},
"context": [{"key": "setting.command_mode"}, {"key": "vi_can_enter_text_object"}]
},
// * g [hjkl] motions
{ "keys": ["g", "h"], "command": "set_motion", "args": {
"motion": "vi_move_to_first_non_white_space_character",
"motion_args": {"extend": true },
"clip_to_line": true },
"context": [{"key": "setting.command_mode"}]
},
{ "keys": ["g", "j"], "command": "set_motion", "args": {
"motion": "vi_goto_line",
"motion_args": {"repeat": 1, "explicit_repeat": true, "extend": true, "ending": "eof" },
"linewise": true },
"context": [{"key": "setting.command_mode"}]
},
{ "keys": ["g", "k"], "command": "set_motion", "args": {
"motion": "vi_goto_line",
"motion_args": {"repeat": 1, "explicit_repeat": true, "extend": true, "ending": "bof" },
"linewise": true },
"context": [{"key": "setting.command_mode"}]
},
{ "keys": ["g", "l"], "command": "set_motion", "args": {
"motion": "vi_move_to_hard_eol",
"motion_args": {"repeat": 1, "extend": true}, "inclusive": true, "clip_to_line": true },
"context": [{"key": "setting.command_mode"}]
},
// -------------------------------------------------------------------------------------------
// vim-unimpaired
{ "keys": ["[", "<character>"], "command": "noop", "context": [{"key": "setting.command_mode"}] }, // safeguard
{ "keys": ["[", "e"], "command": "swap_line_up", "context": [{"key": "setting.command_mode"}] },
{ "keys": ["]", "e"], "command": "swap_line_down", "context": [{"key": "setting.command_mode"}] },
{ "keys": ["[", "t"], "command": "prev_view", "context": [{"key": "setting.command_mode"}] },
{ "keys": ["]", "t"], "command": "next_view", "context": [{"key": "setting.command_mode"}] },
// -------------------------------------------------------------------------------------------
// vim-surround
{ "keys": ["S", "["], "command": "insert_snippet", "args": {"contents": "[${0:$SELECTION}]"},
"context": [
{ "key": "setting.command_mode" },
{ "key": "selection_empty", "operand": false },
]
},
{ "keys": ["S", "{"], "command": "insert_snippet", "args": {"contents": "{${0:$SELECTION}}"},
"context": [
{ "key": "setting.command_mode" },
{ "key": "selection_empty", "operand": false },
]
},
// -------------------------------------------------------------------------------------------
// Clone cursors
{ "keys": ["ctrl+alt+j"], "command": "select_lines", "args": { "forward": true } },
{ "keys": ["ctrl+alt+k"], "command": "select_lines", "args": { "forward": false } },
// -------------------------------------------------------------------------------------------
// <C-w> window management (with Origami commands)
{ "keys": ["ctrl+w"], "command": "noop" }, // safeguard
{ "keys": ["ctrl+w", "c"], "command": "close_pane" },
{ "keys": ["ctrl+w", "ctrl+c"], "command": "close_pane" },
{ "keys": ["ctrl+shift+w"], "command": "close_file" },
{ "keys": ["ctrl+w", "q"], "command": "close_file" },
{ "keys": ["ctrl+w", "ctrl+q"], "command": "close_file" },
{ "keys": ["ctrl+w", "n"], "command": "new_pane" },
{ "keys": ["ctrl+w", "o"], "command": "set_layout",
"args":
{
"cols": [0.0, 1.0], // vertical splitters
"rows": [0.0, 1.0], // horizontal splitters
"cells": [[0, 0, 1, 1]] // x1, y1, x2, y2
}
},
{ "keys": ["ctrl+w", "o"], "command": "unselect_others", "context": [{"key": "group_has_multiselect"}]},
{ "keys": ["ctrl+w", "h"], "command": "travel_to_pane", "args": {"direction": "left"} },
{ "keys": ["ctrl+w", "j"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+w", "k"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+w", "l"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+w", "ctrl+h"], "command": "travel_to_pane", "args": {"direction": "left"} },
{ "keys": ["ctrl+w", "ctrl+j"], "command": "travel_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+w", "ctrl+l"], "command": "travel_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+w", "ctrl+k"], "command": "travel_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+w", "ctrl+h"], "command": "focus_to_left", "context": [{ "key": "group_has_multiselect" }] },
{ "keys": ["ctrl+w", "h"], "command": "focus_to_left", "context": [{ "key": "group_has_multiselect" }] },
{ "keys": ["ctrl+w", "ctrl+l"], "command": "focus_to_right", "context": [{ "key": "group_has_multiselect" }] },
{ "keys": ["ctrl+w", "l"], "command": "focus_to_right", "context": [{ "key": "group_has_multiselect" }] },
{ "keys": ["ctrl+w", "H"], "command": "carry_file_to_pane", "args": {"direction": "left", "create_new_if_necessary": true} },
{ "keys": ["ctrl+w", "J"], "command": "carry_file_to_pane", "args": {"direction": "down", "create_new_if_necessary": true} },
{ "keys": ["ctrl+w", "L"], "command": "carry_file_to_pane", "args": {"direction": "right", "create_new_if_necessary": true} },
{ "keys": ["ctrl+w", "K"], "command": "carry_file_to_pane", "args": {"direction": "up", "create_new_if_necessary": true} },
{ "keys": ["ctrl+w", "alt+h"], "command": "clone_file_to_pane", "args": {"direction": "left"} },
{ "keys": ["ctrl+w", "alt+j"], "command": "clone_file_to_pane", "args": {"direction": "down"} },
{ "keys": ["ctrl+w", "alt+l"], "command": "clone_file_to_pane", "args": {"direction": "right"} },
{ "keys": ["ctrl+w", "alt+k"], "command": "clone_file_to_pane", "args": {"direction": "up"} },
{ "keys": ["ctrl+w", "d"], "command": "clone_file" },
{ "keys": ["ctrl+w", "ctrl+s"], "command": "clone_file_to_pane", "args": {"direction": "down", "create_new_if_necessary": true}},
{ "keys": ["ctrl+w", "s"], "command": "clone_file_to_pane", "args": {"direction": "down", "create_new_if_necessary": true}},
{ "keys": ["ctrl+w", "ctrl+v"], "command": "clone_file_to_pane", "args": {"direction": "right", "create_new_if_necessary": true}},
{ "keys": ["ctrl+w", "v"], "command": "clone_file_to_pane", "args": {"direction": "right", "create_new_if_necessary": true}},
// * zoom
{ "keys": ["alt+z"], "command": "zoom_pane", "args": {"fraction": 0.9} },
{ "keys": ["alt+="], "command": "unzoom_pane", "args": {} },
{ "keys": ["alt+shift+z"], "command": "unzoom_pane", "args": {} },
// * Temporary split with [<C-w>] tab [m]ultiselect
{ "keys": ["ctrl+w", "ctrl+m"], "command": "clone_file", "args": {"add_to_selection": true, "retain_viewport_position": true} },
{ "keys": ["ctrl+w", "m"], "command": "clone_file", "args": {"add_to_selection": true, "retain_viewport_position": true} },
{ "keys": ["ctrl+w", "ctrl+m"], "command": "close_file_without_saving", "context": [{ "key": "group_has_multiselect" }] },
{ "keys": ["ctrl+w", "m"], "command": "close_file_without_saving", "context": [{ "key": "group_has_multiselect" }] },
// -------------------------------------------------------------------------------------------
// <C-j> tab management
{ "keys": ["ctrl+j", "ctrl+o"], "command": "unselect_others" },
{ "keys": ["ctrl+j", "o"], "command": "unselect_others" },
{ "keys": ["ctrl+j", "alt+h"], "command": "unselect_to_left" },
{ "keys": ["ctrl+j", "alt+l"], "command": "unselect_to_right" },
{ "keys": ["ctrl+j", "H"], "command": "select_to_left" },
{ "keys": ["ctrl+j", "L"], "command": "select_to_right" },
{ "keys": ["ctrl+j", "h"], "command": "focus_to_left" },
{ "keys": ["ctrl+j", "ctrl+h"], "command": "focus_to_left" },
{ "keys": ["ctrl+j", "l"], "command": "focus_to_right" },
{ "keys": ["ctrl+j", "ctrl+l"], "command": "focus_to_right" },
// -------------------------------------------------------------------------------------------
// Project management
{ "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" },
// -------------------------------------------------------------------------------------------
// Quick settings / customization
{ "keys": ["ctrl+,"], "command": "edit_settings",
"args": { "base_file": "${packages}/Default/Preferences.sublime-settings" } },
{ "keys": ["ctrl+k", "ctrl+s"], "command": "edit_settings",
"args": { "base_file": "${packages}/Default/Default ($platform).sublime-keymap" } },
{ "keys": ["ctrl+k", "ctrl+p"], "command": "open_file", "args": { "file": "${project}" } },
{ "keys": ["ctrl+k", "ctrl+c"], "command": "select_color_scheme" }, // overrides show_at_center
{ "keys": ["ctrl+k", "ctrl+t"], "command": "select_theme"},
{ "keys": ["ctrl+k", "ctrl+m"], "command": "toggle_minimap"},
{ "keys": ["ctrl+k", "ctrl+r"], "command": "view_resource" },
// -------------------------------------------------------------------------------------------
// BuildX hook for Ctrl[+Shift]+B
{
"keys": ["ctrl+b"],
"command": "build",
"context": [{ "key": "for_buildx" }]
},
{
"keys": ["ctrl+shift+b"],
"command": "build",
"args": {"select": true},
"context": [{ "key": "for_buildx" }]
},
// -------------------------------------------------------------------------------------------
// Autocompletion tweaks
{ "keys": ["ctrl+d"], "command": "auto_complete_open_link", "context": [{ "key": "auto_complete_visible" }, ] },
// -------------------------------------------------------------------------------------------
// <C-n> and <C-p> in autocomplete, overlay and panel
{ "keys": ["alt+j" ], "command": "move", "args": {"by": "lines", "forward": true }, "context": [ { "key": "setting.is_widget" } ] },
{ "keys": ["alt+j" ], "command": "move", "args": {"by": "lines", "forward": true }, "context": [ { "key": "auto_complete_visible" } ] },
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true }, "context": [ { "key": "setting.is_widget" } ] },
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true }, "context": [ { "key": "auto_complete_visible" } ] },
{ "keys": ["alt+k" ], "command": "move", "args": {"by": "lines", "forward": false }, "context": [ { "key": "setting.is_widget" } ] },
{ "keys": ["alt+k" ], "command": "move", "args": {"by": "lines", "forward": false }, "context": [ { "key": "auto_complete_visible" } ] },
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false }, "context": [ { "key": "setting.is_widget" } ] },
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false }, "context": [ { "key": "auto_complete_visible" } ] },
{ "keys": ["ctrl+m"], "command": "commit_completion", "context": [ { "key": "auto_complete_visible" } ] },
{ "keys": ["ctrl+m"], "command": "select", "context": [ { "key": "overlay_has_focus" } ] },
// -------------------------------------------------------------------------------------------
// LSP
{ "keys": ["ctrl+alt+p"], "command": "lsp_hover"},
{ "keys": ["alt+shift+p"], "command": "lsp_document_symbols"},
{ "keys": ["ctrl+k", "l"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "LSP: " } },
{ "keys": ["g", "d"], "command": "lsp_symbol_definition", "context": [{"key": "setting.command_mode"}]},
{ "keys": ["g", "r"], "command": "lsp_symbol_references", "context": [{"key": "setting.command_mode"}]},
// Expand Selection (a replacement for ST's "Expand Selection")
{
"keys": ["alt+a"],
"command": "lsp_expand_selection",
"args": {"fallback": false},
"context": [{"key": "lsp.session_with_capability", "operand": "selectionRangeProvider"}]
},
// Toggle inlay hints
// Accepts optional "enable" argument to specify the expected state instead of toggling.
{
"command": "lsp_toggle_inlay_hints",
"keys": ["alt+i"],
"context": [{"key": "lsp.session_with_capability", "operand": "inlayHintProvider"}]
},
// -------------------------------------------------------------------------------------------
// misc
{ "keys": ["ctrl+k", "ctrl+`"], "command": "generate_command_list" }
]
import sublime
import sublime_plugin
class CloseFileWithoutSaving(sublime_plugin.WindowCommand):
def run(self):
self.window.active_view().set_scratch(True)
self.window.active_view().close()
self.window.active_view().set_scratch(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment