1

I'm using Sublime Text3 with Latexing, and i search to know if it's possible to replace automatically during compilation the regular quote for latex ''mytext"" by \enquote{}

That seems silly but, a) if i want to display french quotes, and not english quote "", i need to use csquote. b) If i use csquote i need to to write \enquote{} and in consequence, i lost the pretty highlighting for this specific syntax ''mytext""

So i search to keep the pretty highlight with csquotes package in french mode, do you think it's possible ?

1

If you look in Preferences > Package Settings > LaTeXing > Keybindings - Default you'll find this key binding:

{
    "keys": ["\""],
    "command": "insert_snippet", "args": {"contents": "``$0''"},
    "context": [
      {"key": "eol_selector", "match_all": true, "operand": "comment.line.percentage", "operator": "not_equal"},
      {"key": "selection_empty", "match_all": true, "operand": true, "operator": "equal"},
      {"key": "selector", "operand": "text.tex.latex", "operator": "equal"},
      {"key": "selector", "operand": "source.r", "operator": "not_equal"},
      {"key": "selector", "operand": "meta.block.parameters.knitr", "operator": "not_equal"},
      {"key": "selector", "operand": "meta.block.parameters.knitr", "operator": "not_equal"},
      {"key": "setting.auto_match_enabled", "operand": true, "operator": "equal"}
    ]
},

which is the one responsible for the autocomplete.

If you put the following

{
    "keys": ["\""],
    "command": "insert_snippet", "args": {"contents": "\\enquote{$0}"},
    "context": [
      {"key": "eol_selector", "match_all": true, "operand": "comment.line.percentage", "operator": "not_equal"},
      {"key": "selection_empty", "match_all": true, "operand": true, "operator": "equal"},
      {"key": "selector", "operand": "text.tex.latex", "operator": "equal"},
      {"key": "selector", "operand": "source.r", "operator": "not_equal"},
      {"key": "selector", "operand": "meta.block.parameters.knitr", "operator": "not_equal"},
      {"key": "selector", "operand": "meta.block.parameters.knitr", "operator": "not_equal"},
      {"key": "setting.auto_match_enabled", "operand": true, "operator": "equal"}
    ]
},

in your User Keybindings (from Preferences) you obtain what you asked.

As for the syntax highlighting, it can be done but you need to modify the .tmLanguage file of LaTeXing, which is more complicated and can potentially break with updates of the package. The idea would be to assign the string scope to the parameter of \enquote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.