Hi,
in Default (OSX).sublime-keymap I see three key bindings for the double-quotes key.
Why?
Which one is actually used when I press a "
(double-quotes character)?
Thanks
Hi,
in Default (OSX).sublime-keymap I see three key bindings for the double-quotes key.
Why?
Which one is actually used when I press a "
(double-quotes character)?
Thanks
It depends on the scope the caretâs in and the state of Sublime Text. This is defined in the âcontextâ of the key binding.
Thank you guillermooo, Iâm starting to see some light.
If more than one scope/state is satisfied, which one takes the precedence (the first? the last?).
Just to be sure:
"key": "setting.auto_match_enabled", "operator": "equal", "operand": true
This means that the setting âauto_match_enabledâ have to be âequalâ to âtrueâ?
Analogously I guess that
"key": "selection_empty", "operator": "equal", "operand": true, "match_all": true
requires that the current selection be empty⌠but what does "match_all": true
means?
Last, but the most important: where I can learn this kind of stuff (in order to avoid these dummy questions)?
I hope this helps:
They are all required to be true.
[quote=âbblueâ]requires that the current selection be empty⌠but what does
CODE: SELECT ALL
âmatch_allâ: true
means?[/quote]
It means all selections need to satisfy the conditions in the context. More on this here:
Thanks again guillermooo.
Actually not so much⌠but maybe I have to read it again and again.
Sorry for having been not so clear: I donât mean among contexts, but among key bindings. But maybe theyâre all mutually exclusive.
Perfectly clear, thank you!
Just one more question, please please please (this discussion is very informative for me!). Beside to this key binding
{ "keys": "\\"], "command": "auto_complete", "context":
{"key": "selection_empty", "operator": "equal", "operand": true, "match_all": true},
{"key": "selector", "operator": "equal", "operand": "text.tex.latex"}
]
}
Iâd like to have another bound to the same keystroke () that manage the case of a non-empy selection (so they will be mutually exclusive). In this case the command should be two-fold: an auto_complete followed by an insert_snippet. How to accomplish this?
Cheers
Maybe I can change something too Anything particulary unclear for you?
[quote=âbblueâ]Sorry for having been not so clear: I donât mean among contexts, but among key bindings. But maybe theyâre all mutually exclusive.
[/quote]
As long as the contexts are different, they should not step on each other, yeah.
[quote=âbblueâ]Iâd like to have another bound to the same keystroke () that manage the case of a non-empy selection (so they will be mutually exclusive). In this case the command should be two-fold: an auto_complete followed by an insert_snippet. How to accomplish this?
[/quote]
In ST1 there used to be a âsequenceâ command that would let you run a series of commands. I donât think thatâs so simple in ST2 now; youâd need to code your own plugin. But by the look of it, your might be better off using other features like .sublime-completions files to do what youâre after. To be honest, I donât think I understand what you want to do!
This is more than I may ask! Give me a couple of days and Iâll tell you. I prefer reading it again before.
Let me explain.
Suppose a sublime-completion file like this:
{
"scope": "text.tex.latex",
"completions":
{ "trigger" : "\\bf", "contents": "\\textbf{${1:[text]}}"},
{ "trigger" : "\\it", "contents": "\\textit{${1:[text]}}"}
]
}
Now, with the key binding
{ "keys": "\\"], "command": "auto_complete", "context":
{"key": "selection_empty", "operator": "equal", "operand": true, "match_all": true},
{"key": "selector", "operator": "equal", "operand": "text.tex.latex"}
]
}
when (in a TeXT/LaTeX file) I press the backslash when there is no selection an auto-completion menu appears, that give me the option to choose between â\bfâ and â\itâ. If, say, I choose the second, the following text will appear:
\textit{[text]}
where the â[text]â is selected, ready to be replaced with what I want. So far so good.
What I really like to accomplish is to manage the situation in which there is a selection when I press the backspace. Say âactual text.â The result now should be that when I select â\itâ from the auto-completion menu, the following text appears:
\textit{actual text}
Clear enough?
Not exactly what you want, but close:
[code]{
âscopeâ: âtext.tex.latexâ,
âcompletionsâ:
{ "trigger" : "\\bf", "contents": "\\textbf{${1:$SELECTION}}"},
{ "trigger" : "\\it", "contents": "\\textit{${1:$SELECTION}}"}
]
}[/code]
This way you only need a key binding.
Also, you can read through this topic:
It works perfectly as far as I select an item with the mouse from the auto-completion menu. But it doesnât work if I use the keyboard for a fuzzy-search of the list (which, in the real-life, is muuuuch longer than the two-items list I gave you as an exampleâŚ).
So, there is no way to assign a list of commands to a key instead of a single one?
Sure I will, thank you.
Yeah, you were talking about âselectingâ items, so I assumed you werenât using the fuzzy search. As soon as you type something in, the previous selectionâs text will obviously be wiped away.
You can still do what you want, but not through the completions list, I believe. You definitely can do it with separate key bindings as explained in the linked post.
Maybe the snippet syntax could be expanded to allow for a place holder to be inserted when a $VARIABLE was empty, like in:
${1:$SELECTION:{[text]}}