I literally created an account to thank you. This is brilliant, something Iāve needed for a while. 
JavaScript completions
Thank you very much csl_.
However, I wasnāt happy with my first version. It requires too much of a change in the way that I code. This is fine for JS, but is likely to be off-putting when switching to other languages. So I have spent many (manyā¦) hours perfecting the (new) attached version. It behaves much more like typical auto-completion. To an extent it is just a word list, but also helps you to complete function arguments.
- Iām not sure how it will play with CodeIntel, but perhaps there is an option for that package to disable it just for JS(?).
- If you already have a JS completions file you might want to (temporarily) move it out of your JS folder, so you can try my version
- You might want to tweak the āauto_complete_delayā property so that the list doesnāt appear too quickly.
The completion list shows details like āanchors // Documentā to remind us which object it applies to;
If you chose the completion āalert()ā, for example, and you havenāt already typed āsomething.ā it will automatically pre-pend āwindowā. Of course, if you donāt like this, then you can just ignore the completion.
If you type your variable name, then a ā.ā, and youāre not sure what methods/properties are available, then start to type the kind of object it is, as in āAreaā or āImageā. This should focus the list to specific items for this kind of object. Otherwise, you could start typing āElementā for more general members. But, of course, you can just type a few letters from the method/property that you want to use.
All style properties are triggered by typing an underscore ā_ā. I did this to try to push them further down the completion list. However, you donāt have to type the underscore if you donāt want to 
(End of part one.)
AndyJS2.zip (10.2 KB)
Iāve made this list as comprehensive as I can. It should include most anything youāre likely to need, including all Canvas related features. (Start typing āCanvasā to focus on these). But there are some omissions:
Some obscure event properties;
HTML5 features (other than Canvas);
Obsolete, and some deprecated, items;
CSS3 properties, and there might be a few missing from CSS 2.2(?);
Some obscure Node/DOM items;
Some browser specific, or not well-supported, features.
But I still have one or two concerns/ things I need to consider:
Local variable names might be pushed further down the list. Iām not sure how much of an issue this might be - if youāre typing within a function then youāre likely to be *happy *to type your variable name in full (or Ctrl-Space might help);
The list is quite long - 800+ lines. (But the PHP version has over 4000 lines!) If it proves to be too slow then it might require a little trimming.
But my main concern is this: because the tab-trigger includes help text - such as āmaxLength // Password/Textā - this means that there will be far more matches appearing in the list than I want. My thoughts are these:
Live with it, because of all the help that it provides!
Abbreviate all the object names in the help text, such as āPwdā, āTxtā, āDocā etc. But this means you/me remembering the abbreviations. It might also mean that we end up with some unexpected matches;
Remove the help text altogether (and re-order the file) - a tough decision!
Try and compact object names; that is, put all specific items relevant to āPassword/Text/TextAreaā, etc., under the single heading āInputā. I could consider this, but it just makes the list less helpful, particularly to new coders.
Anyway, I will be very pleased to receive feedback and suggestions. In particular, if Iāve missed something obvious that should be in the list
.
Regards, Andy.
By the way, **loving **this Editor

Iāve only had it ten days, and Iāve learnt about Snippets, completions, JSON, tmLanguage, TextMate variables, revised the whole of JavaScript and a bit on Regular Expressions⦠Iām even intending to read a book I have on Python!
(My only issue is that when I use Replace it also adds a chunk of text left over from a previous document - any idea how I can clear this cache/buffer pl?)
Regards, Andy.
Hello. My work here is done
and Iāve attached my final JS completions file, enjoy!
There is a lot of good stuff in it, but Iām not foolish enough to say itās complete. I think it is as comprehensive as it can be, for a single file.
Of course, the advantage of it being a completions file, rather than a complex Python script, is that you are free to add, delete, move items as you wish.
As mentioned previously, I donāt think it will work well with CodeIntel, unless you are able to turn that off just for JavaScript(?).
Please let me know if you discover any mistakes
or obvious omissions.
The object names you can use to try and narrow a search are:
Anchor, Area, Array, Attr, Body, Canvas, Date, Document, Event, Form, Frame, Frameset, Function, History, Image, Input, JSON, Link, Location, Math, Meta, Navigator, Number, Object, object, Option, RegExp, Screen, Select, String, Table, TD,H,R, TextArea, Window. (And an underscore ā_ā for style properties.)
I removed the term Element, as everything is an element and it wonāt help narrow a search;
Rather than Date it might work better to type day, month, etc., get, set, or to;
If manipulating the DOM try words like node, create, append, child, sibling.
All the best and, as before, I would very much appreciate any feedback. Andy.
AndyJS3.zip (10.1 KB)
Have been looking at version 2 just the moment you released version 3 
The first thing I stumbled upon is the completion after typing āifā which is āmimeTypes FF ā¦ā (somewhere down the list). Any Ideas why this is happening? If I complete with TAB, undo and TAB again I get āif (true) {};ā as expected.
Hello senzo.
I havenāt got your exact behaviour in version 2 or 3. I think itās because ST takes a semi-intelligent approach to suggesting completions. That is, it remembers what youāve used previously. To resolve this:
type āifā and scroll in the completion to select āif () { }ā;
perhaps start a new js file in the same project and try the first step in this file;
type āifā, press escape to dismiss the completions list, and press tab a couple of times.
I notice in the projectās workspace file it maintains a list of āselected-itemsā for āauto-completeā. You could try carefully! deleting this to start over, or just the bits that you know are not useful. But make sure that you close the project (or use a different editor) before you amend this file.
Of course, itās possible to remove items, or move them further down, within the completions file - but I would always treat this as a last resort.
Let me know, Andy.
Actually, this has resolved a problem I was having when trying to replace text
(it was replacing it with a chunk of text from a previous file).
I closed my Project, and open the workspace file thatās in my project folder. I delete all of the auto-complete history (leaving just ] ) and did the same for the replace history.
Then I closed ST and re-started - Great!
There are other things that can be deleted (carefully) in the workspace file, such as file_history items, which can fix and speed-up things, wheāhay.
Andy.
Sorry to be a pain, but I noticed a small error with āparse()ā and āUTC()ā and have corrected this in the attached. Iām fairly confident that there arenāt too many such errors
, but let me know pl.
Iāve managed to make a start with GitHub, but I havenāt fully sussed it yet. Iāll post the link when Iāve defeated it!
Andy.
AndyJS3.zip (10.1 KB)
Hello again.
I thought everything was going to well, and Iāve discovered and issue that needs to be raised. My expression
${TM_CURRENT_LINE/.+\.$|(.*)/(?1:document\.)/}
works well, in that:
alink
becomes
document.alinkColor
and
myDocu.alink
becomes
myDocu.alinkColor
Thatās fine, but if anything at all occurs *after *the text that youāre typing it will always put in ādocumentā
. So if you are typing within brackets ( ) then we have an issue. To get around it for the moment we can just type āalinkā and let ādocumentā be added, or type what we need directly.
Iāll need to work on my regex so that it only reads upto the current cursor position. It shouldnāt be too tricky, but it might take me a little while. Andy.
Well that was hard work
but Iāve finally got the expression I need:
${TM_CURRENT_WORD/\.\W*|(.*)/(?1:document\.)/}testThis
Iāll need to test it a bit more and then Iāll update my file tomorrow.
Basically, it means that typing āsomething.testtā should become āsomething.testThisā, not matter where you type it; that is, even if nested deeply within a statement or brackets. The only time it will (should!) become ādocument.testThisā is if you type ātesttā without an initial dot.
Andy.
Attached is the corrected version 3. Iāll update GitHub to reflect this tomorrow.
Andy.
AndyJS3.zip (10.1 KB)
This will be my last update, you might be pleased to hear
, because Iāve got this GitHub thing working (link provided in previous post).
I have used abbreviations in the tab triggers by removing the bracketed text shown:
Canvas 2(d)
CanvasGrad(ient)
Func(tion)
Hist(ory)
Navig(ator)
The purpose of this is to reduce the number of mis-hits when typing, without losing the ability to track down these specific objects. It also reduces the file size very slightly.
Iāve kept the full words Document, Window, Location, etc., because these terms are so familiar, and abbreviating them doesnāt assist searching. However, Iāve removed the text āDateā from the triggers. This is because itās much easier to type day, month, time, etc., or get, set, to, UTC. Iāve kept them for the static functions parse() and UTC() though.
Iām not intending to play with this any more (unless someone points out omissions or mistakes), as I want to play with Python! Regards, Andy.
[quote=āelkraneoā]Many THX Andy!
any clues how to add syntax colors to the functions ?[/quote]
This would require modifying the āJavaScript.tmLanguageā file and your chosen theme-file. Itās not straight-forward unfortunately
. Alternatively, you might find an existing theme that includes specific JS syntax colours. If you find such a theme, you could modify its ātmThemeā file to change some of the colour-numbers. I donāt know which themes include JS colours 
Andy.
any thread about this on userecho?
itās quite painfull using this forum since there are no mail notificationsā¦
Would you mind continuing the discussion here:
http://sublimetext.userecho.com/topic/94863-poor-or-non-existant-javascript-autocompletion/
[quote=āagibsonswā]
[quote=āelkraneoā]Many THX Andy!
any clues how to add syntax colors to the functions ?[/quote]
This would require modifying the āJavaScript.tmLanguageā file and your chosen theme-file. Itās not straight-forward unfortunately
. Alternatively, you might find an existing theme that includes specific JS syntax colours. If you find such a theme, you could modify its ātmThemeā file to change some of the colour-numbers. I donāt know which themes include JS colours 
Andy.[/quote]
THX Andy, great work
@agibsonsw - Apologies for adding to such an old thread. Butā¦
Iām just starting looking at completions and other aspects of modifying Sublime Text 4.
The documentation is⦠sparse to be polite. Or it assumes a massive amount of background information in code bases I donāt know about.
Can I ask if you found better information on Sublime Text completions and so on somewhere?
Youāve clearly worked hard to get an understanding of how it all works.
But I look at the docs and its barely comprehensible to me. If there were indications of other reading to find out how to make it work, that would be great. But there isnāt.
Thanks for any thoughts. 