Since ST4, I noticed that the cursor stays before the ;
when I auto complete a CSS property. I have to type right arrow on my keyboard to write another property. If I have 5 properties to write, I need to press a useless input to place the cursor after the ;
and hit return. Here is a video of the issue:
ST4 bad cursor placement after auto completing a CSS property
You can type ;
and the cursor will “go over it”, like with parentheses and curly brackets in other languages.
The default CSS
package that ships with ST has a key binding, where pressing enter before a ;
will automatically move the cursor to the next line without transferring the semi colon at the end.
The same key binding can be utilized for sass as well by just changing the selector
context.
// Move the caret to the next line and leave the terminating semicolon untouched.
// This is to not bother with semicolons even though completions end up with the caret directy in front of it.
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} , "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "source.scss - meta.selector.css", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": ";\\s*$", "match_all": false },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\s*;", "match_all": false }
]
},
With this, now you don’t need to go back to the previous property to place the cursor after ;
Actually, this functionality stopped working for me in ST4. I searched the problem which led me to this thread.
All the other “go over it” moments still work. Parenthesis and brackets. When I type the closing character, it correctly goes through the auto-completed character.
But not semicolons. It did used to work that way, but has since stopped. I get the same behavior as in the OP video, and when I press semicolon again it just puts a duplicate semicolon there.
Is there some setting or keybind I can look for to make sure I have this functionality configured correctly?
You might want to double check that you don’t have either an override on the default key bindings (use Preferences > Browse Packages
; do you see a Default
folder? If so, any file in there is blocking the ST4 update of that file from taking effect) or that you don’t have a custom key binding on that key (or more possibly, that a package isn’t interfering).
A simple check is to start ST4 in Safe Mode and see if you can replicate the issue there.
Hey there, thanks for the quick reply!
Preferences > Browse Packages
does not have a Default folder, so that’s good.
As it turns out I forgot to mention this happens in SCSS files, not plain CSS. Safe Mode made me realize this, as it disabled the SCSS syntax package, which makes auto-complete broken entirely. However I checked a normal CSS file inside and outside of Safe Mode, and the semicolon works properly. In standard CSS files my semicolon correctly “goes over” an existing semicolon.
I tried uninstalling and reinstalling the SCSS syntax package, but that did not help. So I jumped over to the package page here: https://packagecontrol.io/packages/Sass, where it says that the keybindings had been removed in a recent version due to upgrades to the ST keybindings. But those old keybindings are exactly what isn’t working anymore!
So for anyone in the future: just go here and add your SCSS keybinding back. That fixed my issue