Sublime Forum

How to set shortcut for menu "View => word Wrap"?

#1

Hello.

I’ve tried to set shortcut to menu “View => word Wrap” and I’ve failed.
I’d like to switch between **“word Wrap” ** on/off within keys ctrl+t+w.
I’ve opened “Preferences => Key Bindings - User” and here is conent:


{ "keys": "ctrl+t+w"], "command": "toggle wordWrap" }
]

I’ve saved this settings with ctrl+s
Then I’ve opened my txt file containing long strings and I’ve tried to use ctrl+t+w.
There were no effect.
What is the problem?
How can I bind chortcut ctrl+t+w to menu item **“word Wrap” **?

1 Like

#2

[quote=“dmarsentev”]Hello.

I’ve tried to set shortcut to menu “View => word Wrap” and I’ve failed.
I’d like to switch between **“word Wrap” ** on/off within keys ctrl+t+w.
I’ve opened “Preferences => Key Bindings - User” and here is conent:


{ "keys": "ctrl+t+w"], "command": "toggle wordWrap" }
]

I’ve saved this settings with ctrl+s
Then I’ve opened my txt file containing long strings and I’ve tried to use ctrl+t+w.
There were no effect.
What is the problem?
How can I bind chortcut ctrl+t+w to menu item **“word Wrap” **?[/quote]

  1. I don’t think you can use “t” as a modifier key. As far as I know, only “ctrl”, “shift”, “alt”, and “meta” can be modifier keys.

2.Your command would not work anyways; “toggle wordWrap” is not a command.

  1. Do this (change shortcut to what you want only using accepted modifier keys; this is tested, and does work):

{ "keys": "ctrl+shift+w"], "command": "toggle_setting", "args": {"setting": "word_wrap"}} ]

4 Likes

#3

Maybe he means: { "keys": "ctrl+t", "ctrl+w"], "command": "toggle_setting", "args": {"setting": "word_wrap"}} ]

3 Likes

#4

You’re also missing the left square bracket after “keys”:

{ “keys”: [“ctrl+t”, “ctrl+w”], “command”: “toggle_setting”, “args”: {“setting”: “word_wrap”}}

2 Likes

#5

Hello!

something you’re going to need when you want to set shorcuts:

sublime.log_commands(True)

Paste this in the console (view -> show console), and each time you run a command, it logged!

sublime.log_commands(False) to stop it

Here’s a little plugin that I created that allows you to do

  • cmd1 and it runs sublime.log_commands(True)
  • cmd0 for sublime.log_commands(False)
  • ipt1 for sublime.log_input(True): log key pressed
  • ipt0 for sublime.log_input(True): stop logging key pressed

Matt

2 Likes

#6

This works, but ctrl-shift-w is "command": "close_window" by default, so I just use

{ "keys": ["ctrl+w"],
      "command": "toggle_setting",
      "args": {
        "setting": "word_wrap"
      }
    }
0 Likes

#7

And Ctrl+W is close active view, by default. For you, it is ok to override Ctrl+W?

{ "keys": ["ctrl+w"], "command": "close" },

Personally, I use "Ctrl+K", "Ctrl+Q" to toggle word wrap:

{ "keys": ["ctrl+k", "ctrl+q"], "command": "toggle_setting", "args": {"setting": "word_wrap"} },
0 Likes