Sublime Forum

Customizing key bindings

#1

{ "keys": ["<"], "command": "insert", "args": { "characters": " < " }, "context": [{ "key": "selector", "operator": "equal", "operand": "source.js" }] }

i don’t want the spaces around < or > to be added when i write an html tag within js, for example:

document.write(" < br / > ");

how do i change that?

0 Likes

#2

replace source.js with source.js - string

3 Likes

#3

and how to remove the spaces around + in expressions such as i++?

0 Likes

#4

I wish there was a built-in command to call multiple commands without having to resort to macros …

Packages/User/revert_surrounding_spaces_plus.sublime-macro

[
    { "command": "left_delete" },
    { "command": "left_delete" },
    { "command": "left_delete" },
    { "command": "insert", "args": {"characters": "++" } }
]

Key binding:

  { "keys": ["+"], "command": "run_macro_file",
    "args": {"file": "Packages/User/revert_surround_spaces_plus.sublime-macro"},
    "context": [
      { "key": "preceding_text", "operator": "regex_contains", "operand": " \\+ $", "match_all": true }
    ]
  }
0 Likes

Auto spacing and quoting inside square brackets
#5

thanks for the help but well, maybe i forgot to mention that what i needed was the spaces to be deleted when ++ is typed, and not be deleted when + is typed, is this even possible?

0 Likes

#6

That’s exactly what it does. Did you try it?

1 Like

#7

Hey,

Maybe it is good thread to ask this question:

I need to use polish diacritical marks. Somehow i can’t type ą = alt + a / ż= alt + z / etc …

How can I find those key bindings and override them by diacritical marks?

Thank you

0 Likes

Polish characters suddenly stopped working
#8

Are you sure those are not typed using ctrl+alt+…? Ctrl+… Are usually reserved for the program and especially ctrl+z is a very basic binding.

0 Likes

#9

Yeah I made terrible mistake. Not CTRL but ALT ;D

My bad …

0 Likes

#10

I type Lithuanian characters on a US keyboard in Windows, by setting the input/keyboard language to Lithuanian and then the number key row becomes Lithuanian characters. Maybe you can do something similar for Polish?

i.e.

1 => ą
2 => č
3 => ę

that way you can enter the characters in any application, and not need to mess around with keybindings

0 Likes

#11

I know it is in polish but you see how it works on your computer :slight_smile:

You mean by that configuration? I have it right now when it is not working:

0 Likes

#12

Lithuanian keyboard looks like this:

which is basically the same as the US English one except for the number row.

but Polish programmers one has no Polish characters on it and 214 version looks like this:

so you could try the 214 version, and press [ for ż, ] for ś etc. (assuming you have an English style physical keyboard.)

0 Likes

#13

Didn’t helped ;<

0 Likes

#14

Guess you’ll have to use keybindings then:

{ "keys": ["alt+z"], "command": "insert", "args": { "characters": "ż" } },
0 Likes

#15

Almost there ;D

I forgot i need right Alt not left. And it doesn’t work with SHIFT to do capital letters :<

0 Likes

#16

and

{ "keys": ["shift+alt+z"], "command": "insert", "args": { "characters": "Ż" } },

for me, pressing right alt+z is treated as ctrl+alt+z so you could try adding ctrl+ to the keys in the keybinding to allow you to use right alt instead of left alt.

1 Like