Sublime Forum

Multi char auto complete trigger

#1

Hello, when writing c++ I want to auto complete on “::” not on “:”. Does anyone know how to achieve that? Thanks in advance.

0 Likes

#2

Is this what you’re looking for? http://docs.sublimetext.info/en/latest/reference/settings.html?highlight=auto_complete_triggers

0 Likes

#3

Partly yes, but if i set the trigger to “::” it will also complete me when typing only one “:”. But I only what it to be triggered with “::”.

0 Likes

#4

Your best option for this is a key binding.

Add the following to your user bindings. It will only be active in C++ files. Adjust the selector line if you need it otherwise. You’ll also need the Chain of Command package.

  { "keys": [":"], "command": "chain",
    "args": {
      "commands": [
        ["insert", {"characters": ":"}],
        ["auto_complete"]
      ]
    },
    "context": [
      { "key": "preceding_text", "operator": "regex_match", "operand": ":$" },
      { "key": "selector", "operand": "source.c++" },
    ]
  },
1 Like