How do I change the keymap to add a caret emphasis in Sublime Text?

How do I change the keymap to add a caret emphasis in Sublime Text?

The default is used ctrl + left mouse, I want to change to alt + left mousefor example a PhpStorm keyboard.

+3


source to share


1 answer


Sublime Text uses sublime-keymap files for keyboard shortcuts and sublime-mousemap files for mouse actions. Your question is obviously related to mouse shortcuts, but there are also some keyboard related commands for adding templates, so I'll cover those as well.

Mousemap

Open the user's mousemap file in

Packages / User / Default (Linux / Windows) .sublime-mousemap (*)

Add an entry:

{
    "button": "button1", "modifiers": ["alt"],
    "press_command": "drag_select",
    "press_args": {"additive": true}
},

      

Change the button and modifiers for additional customization.

You can also use row and column variations:

    "press_args": {"by": "lines", "additive": true}
    "press_args": {"by": "columns", "additive": true}

      

to select entire rows or columns. If you click without dragging on the column selection, the caret will just be added, so you can customize the columns option and only use the column selection when you need to.

See the default mousemap for more examples and options

Packages / Default / Default (Linux / Windows) .sublime-mousemap

(*) To access it directly from Sublime Text you can use the PackageResourceViewer plugin



If you prefer your own commands / shortcuts, create an entry in some sublime command 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 key card file (select 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"} }

      

Layout

In addition to carriage duplication, which occurs when multiple entries are selected, there are commands to duplicate carriage on lines above or below.

Open the user's keyword 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.

Cautions

Sublime Text can have multiple shortcuts for each command, and adding a user shortcut does not deactivate the default shortcuts. For example, if you want to disable some of the annoying default mouse behaviors, you have to:

  • copy the default Mousemap from your default unpacked package (the PackageResourceViewer can't seem to extract it, so do it manually by adding the .zip to the sublime package if needed).
  • paste it into default folder
  • uncomment the entries you want to ignore.
+3


source







All Articles