Sublime Forum

Quotation mark snippet after dot

#1

Hello everyone,

I use ST3 in Windows 10. Consider the following scenario. I write some plain text and forget to put quotation marks around some text that is located at the end of the sentence (as an example, assume “dolore magna aliqua.”). When I try to add the quotation marks by positioning the cursor at the appropriate location (without a selection), this is what happens:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et "dolore magna aliqua."" Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.

The snippet creates two quotation marks after the period, which is annoying. My understanding is that this is the key-binding that triggers the snippet:

{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context":
	[
		{ "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": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
		{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true },
		{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true }
	]
},

I tried to add a . inside the character class in the following line: { “key”: “preceding_text”, “operator”: “not_regex_contains”, “operand”: "[\“a-zA-Z0-9_]$”, “match_all”: true }, resulting in the following key-binding:

{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context":
	[
		{ "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": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
		{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_.]$", "match_all": true },
		{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true }
	]
},

However, the snippet is still triggered. My limited understanding of regex is that I do not have to escape a dot inside a character class. I also tried to add \\., which did not have any effect either.

What am I doing wrong?

Any help is appreciated. Thanks!

0 Likes