Sublime Forum

[ST4] Control autocompletion

#1

SublimeText 4 has some more autocompletion functions, which is very nice. However, I am seeking to control these features. In particular, in a C++ code, when I type

/**

and press enter
I get

/**
 * 

But I’m looking to either remove the inserted * or change the default indentation. Just to clarify the latter, by default the alignment is as follows:

/**
 * This is my docstring.

but I want the first character to respect my default indentation of 4 to get

/**
 *  This is my docstring.
0 Likes

#2

That’s not an auto complete feature. It’s caused by two key bindings that was added in Build 4050

{ "keys": ["enter"], "command": "insert", "args": {"characters": "\n* "}, "context":
		[
			{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
			{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
			{ "key": "selector", "operator": "equal", "operand": "source comment", "match_all": true },
			{ "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*\\*", "match_all": true },
			{ "key": "following_text", "operator": "regex_match", "operand": "(?!/).*", "match_all": true },
			{ "key": "is_javadoc", "operator": "equal", "operand": true, "match_all": true },
		]
	},
{ "keys": ["enter"], "command": "insert", "args": {"characters": "\n * "}, "context":
		[
			{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
			{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
			{ "key": "selector", "operator": "equal", "operand": "source comment", "match_all": true },
			{ "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*/\\*[*!]", "match_all": true },
			{ "key": "following_text", "operator": "regex_match", "operand": "(?!/).*", "match_all": true },
			{ "key": "is_javadoc", "operator": "equal", "operand": true, "match_all": true },
		]
	},

You can copy the above keybindings to your user key bindings and use "characters": "\n" to effectively disable these bindings.

2 Likes

#3

Thanks a lot! That is really helpful!

0 Likes