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. 