Sublime Text 3 - CSS Autocomplete WITHOUT typing property value - html

So I know autocomplete works great when you start typing a value. For example, the second you type the "c" in text-align:center, the available autocomplete values pop up (such as center, left, right).
However, when I used Dreamweaver, for properties with specific value options like text-align (center, right, left), display (block, inline-block), cursor (pointer, default), etc., the autocomplete popup would show immediately after the property was typed, it did NOT wait until I started typing a value. Right after text-align: was typed out, it would show me the autocomplete popup giving me the options center, right, left.
The value autocomplete should fire right after my property autocomplete fires:
So after I type te...
the autocomplete popup for "te" properties displays text-align, text-decoration, text-shadow etc....
then I press Enter to select text-align...
then immediately after pressing Enter an autocomplete popup should show for the text-align values: center, left, right.
Any idea how this can be accomplished in Sublime Text 3?

You can get ST to show the autocompletion popup again straight after a completion has been inserted using a small plugin and some preferences:
With a CSS file open in ST, open the Preferences menu and select Preferences - Syntax Specific. Add the following to the settings on the right hand side:
"auto_complete_triggers":
[
{
"characters": ": ",
"selector": "source.css meta.property-list.css meta.property-value.css"
},
],
and save it. This will tell ST to show the autocomplete popup automatically in CSS files when typing a : or a space when the syntax expects a property value.
Now, unfortunately, ST doesn't consider an autocompletion to have "typed" anything, so this trigger isn't fired automatically when selecting a property value like text-align from the autocomplete popup, which inserts text-align:. So, to get round that, this is where we need a small plugin. From the Tools menu, choose Developer -> New Plugin...
Select all text and replace with the following and save it, in the folder ST recommends (Packages/User/) as something like show_autocomplete_after_completion.py:
import sublime
import sublime_plugin
class AutoCompleteListener(sublime_plugin.EventListener):
def on_post_text_command(self, view, command_name, args):
if command_name in ('commit_completion', 'insert_best_completion'):
act = view.settings().get('auto_complete_triggers', [])
scope = view.scope_name(view.sel()[0].begin())
char = view.substr(view.sel()[0].begin() - 1)
for trigger in act:
if sublime.score_selector(scope, trigger['selector']) > 0:
if char in trigger['characters']:
view.run_command('auto_complete', { 'insert_best_completion': False })
break
This plugin basically detects when a completion has been inserted (although due to a limitation of the ST API, it can't detect when you click on an entry with the mouse - see https://github.com/SublimeTextIssues/Core/issues/1166), and if the text/character immediately before the caret matches one of the autocompletion triggers defined in the settings, then it will show the autocomplete popup again.

You can try out this package. This package indexes your .less and .scss (or .sass) and caches your mixins, variables, class or id names and autocompletes both on html and css. It autocompletes your less and sass mixins with mixin arguments. It also supports emmet completions and gets your css classes on popup window. -
https://github.com/subhaze/CSS-Extended/

Related

How to fix Angular bug requiring user to click a separate element before choosing a second mat chip

Here is the link for an example of the issue I will attempt to describe. In the chips autocomplete example, click the text box to select a new fruit.
Now, before clicking anywhere else, click again on the text box as you did before.
This should result in no options showing up. The issue here is that the user must either begin keying in a new selection or first click another element in the window before matchip will show the options to choose from. I am wondering if there is a way to fix this issue. I would like a user to be able to choose a selection from the list and then immediately click the text box as they had before and make a new selection.
I'm using mat-chip-list inside an outer *ngFor iterating over a FormArray.
Here is what I'have done. It's pretty efficient :
<input
#validatorInput
#operationTrigger="matAutocompleteTrigger"
[formControl]="contactCtrl"
[matAutocomplete]="auto"
[matChipInputFor]="chipList"
(blur)="contactCtrl.setValue(''); validatorInput.value='';"
(click)="contactCtrl.setValue(''); validatorInput.value=''; operationTrigger.openPanel()">
The trick is
Always clear your html input and your (shared) formControl with an empty and not null value each time the blur and click events occur.
Do NOT do this 'clear' on the input focus event. (Because when you delete the last chip, the input is auto-focus and you will have the famous Expression has changed after it was checked.
Call operationTrigger.openPanel(); when the user click on the input
Setting contactCtrl.setValue(''); allows your autocomplete panel to be automatically opened when you call operationTrigger.openPanel()
Setting validatorInput.value=''; is just a way to properly sync your formControl with the html input to ensure a good UX/UI behavior.
Inside my formArray, the formControl is the same for all the inputs but it does not matter since the user can only manipulate one input at a given time
Since you didn't post your code and you mention the example on the material site I'm going to do it as a fork of the stackblitz example they have on their site.
But this will allow you to open the autocomplete panel again despite having had the cursor there and choosing an option previously.
// Using MatAutocompleteTrigger will give you access to the API that will allow you to
// to open the panel or keep it open
...
#ViewChild(MatAutocompleteTrigger, {static: false}) trigger: MatAutocompleteTrigger;
...
ngAfterViewInit() {
fromEvent(this.fruitInput.nativeElement, 'click')
.pipe(
tap(() => {
this.trigger.openPanel()
})
).subscribe()
}
Link to the full stackblitz:
https://stackblitz.com/edit/angular-sb38ig

Tracking Link Click on Google Tag Manager

I want to track clicks on the following button/link with Google Tag Manager. I created a trigger in Google Tag Manager that triggers when the element_id = 100. This works fine, except that when I click exactly on the text, it doesn't do anything, the link looks like a button, with the text in the middle of it. I can't change anything to the html or css, otherwise I can think of multiple things, so I need to find a solution without changing the html. Also, the 'myclass' class and the 'label' class get used in other elements.
<a class="myclass" id="100" href="http://www.url.com">
<span class="label">Text</span>
</a>
Anyone an idea?
Thanks a lot,
The following workaround worked:
Create trigger when element text contains "Text". This will trigger events on the button and the label on the button, of all buttons with "Text" as label.
Create tag for that trigger that checks with simple javascript if either the id of the current element = 100, which will happen when you click the button but not the label, or that the id of the parent = 100, which happens when you click the label. You can get the element that triggered the tag using the built-in variable "Click Element". Which you need to access the parent element.
Technically, you shouldn't have a CSS ID that starts with (or is) a number, so not sure if your code example is accurate or not. Whatever the case, you're probably better off using "matches CSS selector" so that you don't need to use any custom JS.
If indeed your HTML uses id="100", then the above will work. If it's anything else that doesn't start with a number, then you can use
#whatever > span

How to remove colon in Emmet+Stylus in JetBrains IDE

How to remove colon in Emmet+Stylus in JetBrains IDE?
For example, I type mb10 + tab and get margin-bottom: 10px
but it mast be a margin-bottom 10px (without the colon :)
How to disable it?
Currently it is not possible unfortunately.
https://youtrack.jetbrains.com/issue/WEB-15575 -- watch this ticket (star/vote/comment) to be notified on any progress.
the auto-completes that emmet give's you for somethings like mb10 or ovh or bd10 are coming from a fuzzy search result, and I'm almost sure that It's not editable (at least in an easy way)
but you can change somethings about emmet, and in your case
It's done in this way
CTRL + ALT + S (open's up settings panel)
go to the path editor > CodeStyle > liveTemplates
expand Zen CSS
scroll down and find mb, click on it
at bottem of settings panel you should be able to see a field called Template text
change It to this margin-bottom $VALUE$;
click on ok and it's done
if you do mb + tab the output would be margin-bottom ; with the caret instead of $VALUE$ , so you can insert it then and get out of it easily by tab key
but as I said , its not responsible for something like mb10 , because it's referring to a fuzzy search

How to show dropdown when minLength is 0 ngInputTag?

I am using ngTagInput library ref: http://mbenford.github.io/ngTagsInput/ which I customized a little to meet my requirement.
Now I want dropdown be shown with fetched data as soon as input is focused.
E.g.
users = ["stack" ,"subj" ,"owner"];
1. Now on focusing input ("Add User"), all three users should be fetched.
2. After I input "s",then, only "stack" and "subj" should be shown.
For that, I tried ng-focus= "newTagChange()" instead of ng-change="newTagChange()".
But it didn't work as expected.
I also tried with minLength="0" which failed as well.
Find current implementation at:Plunker http://plnkr.co/edit/shgh40H3Nc0eEeM4Lidd?p=preview
Please suggest.
That feature is now available in the master branch of the project on GitHub. You might want to rebase your fork on top of it.
Here's how to enable that behavior:
<tags-input ng-model="tags">
<auto-complete source="loadTags($query)"
load-on-empty="true"
load-on-focus="true">
</auto-complete>
</tags-input>
Setting loadOnEmpty to true will make the directive call the load function when the input content becomes empty, and setting loadOnFocus to true will do the same when the input gains focus.

How do I disable Emmet's CSS Abbreviations in Sublime Text 2

I really like how Emmet generates HTML based on 'CSS-like' strings but I don't want to use their CSS Abbreviations. Cause when I write a piece of css as follows:
li a|
And I press 'TAB', I want to get a Tab
li a |
But with Emmet I get the following when I press Tab
li |-webkit-appearance: none;
-moz-appearance: none;
appearance: none
How can I disable this functionality of Emmet?
In Emmet.sublime-settings you have to update disable_tab_abbreviations_for_scopes property: add source.css to disable Tab trigger completely in CSS.
Also, if you’re on ST2, you may want to take a look at disable_tab_abbreviations_for_regexp preference due to some bugs in ST2 scope matcher.
If you installed with package control, search for Package Control: Remove Package in the command palette. Otherwise you can just remove the Emmet directory.
If you wish to use a custom caption to access commands, create Default.sublime-commands in your User folder. Then insert something similar to the following.
[
{
"caption": "Package Control: Uninstall Package",
"command": "remove_package"
}
]
Of course, you can customize the command and caption as you see fit.
Or try like this: CTRL + SHIFT + P >> Remove Package >>
Select package to remove then press enter
Instead of pressing Tab, you can use Shift+Tab to insert a tab without triggering the tab trigger.
It’s documented in the Sublime Text documentation.
Preferences.sublime-settings - toggle on/off is there.