I’m trying to make a key binding which would run a command only if the selection does not contain only whitespaces.
The selection must contain at least one non-whitespace character to run the command and I’m not concerned about the text preceding and following the selection.
According to the unofficial documentation there is no such context key for testing against the selection only. following_text and preceding_text will look at text inside the selection, but of course also outside which I don’t want.
Something like selected_text would be great. I looked through the default .sublime-keymap file but found nothing similar. I was hoping for an undocumented key.
There is also the $SELECTION part available in contents, for example this would insert “newtext” after the selection:
"command": "insert_snippet", "args": {"contents": "${0:$SELECTION}newtext"},
so maybe there is a way to modify that to include some regex.
