Sublime Forum

How to tell a key binding to use the current selection as an argument

#1

I wanted to use the keyboard for ignoring/adding words in my doocuments. I started by entering >>> sublime.log_commands(True) in the console and observing that the command for ignoring a word with the ST3 spell check is called ``command: ignore_word {“word”: “foo”}```.

I assume this key binding…

{ "keys": ["ctrl+alt+"i"], "command": "ignore_word", "word": "foo"},

…would work for the specific instance of ignoring the word "foo". But how do I tell ST to accept either my current selection, or, even better, the word under my cursor as the string for the argument "word" of the command "ignore_word"?

I tried to search for it, but I couldn’t find anything. Thanks in advance for your help.

0 Likes

#2

For argument(s):

{ "keys": ["ctrl+alt+i"], "command": "ignore_word", "args": { "word": "foo" } },

For passing current selection:
It looks like there is no such a functionality…
http://docs.sublimetext.info/en/latest/reference/key_bindings.html

0 Likes

#3

You’ll probably need to create your own plugin to get the word under your cursor or selection and then pass that clue to the Ignore words command. Your looking at probably 10 lines of code for everything.

0 Likes

#4
0 Likes

#5

Except you shouldn’t use sublime.active_window().active_view() if you already get handed a view object.

0 Likes

#6

if you use cloned views , groups and multiple windows you better use active_view because sublime confuses the views very frequently.

0 Likes