Sublime Forum

C auto-complete help needed

#1

Well I use C improved and it works great also auto complete brackets like:

{} () "" '' ..... work well and are very useful manytimes…but however limited.
Is there a way to add more auto-complete features to Sublime like:

/*....*/ or <...> or <!-- ..... --!>

I tried using key-bindings but it only uses bindings for actions…
Could anyone help??

P.S : This my first post so Hello Everyone! Also if I posted in the wrong section I’m sorry

0 Likes

#2

Here’s how it works for <<…>> in Sublime-Erlang. You can probably adapt this for // style comments.

The first binding inserts >> when << has been typed.

{ "keys": "<"], "command": "insert_snippet", "args": {"contents": "<$0>>"}, "context": { "key": "selector", "operator": "equal", "operand": "source.erlang" }, { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "preceding_text", "operator": "regex_contains", "operand": "^<]<$", "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|>|]|;|\\.|\\}|$)", "match_all": true } ] }

The second binding adds type-over for closing angle brackets.

[code]{ “keys”: “>”], “command”: “move”, “args”: {“by”: “characters”, “forward”: true}, “context”:

		{ "key": "selector", "operator": "equal", "operand": "source.erlang" },
		{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
		{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
		{ "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }
	]
}

[/code]

The third binding deletes an entire <<>> with one keypress when the cursor is in the middle.

{ "keys": "backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Sublime-Erlang/Delete 2 Characters Left and Right.sublime-macro"}, "context": { "key": "selector", "operator": "equal", "operand": "source.erlang" }, { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "preceding_text", "operator": "regex_contains", "operand": "<<$", "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^>>", "match_all": true } ] }

0 Likes