Home Download Buy Blog Forum Support

autocomplete of &... special characters

autocomplete of &... special characters

Postby HenryG on Wed Jul 03, 2013 2:28 am

Just started using ST2 for CFML etc. and love it. Impressed with everything it can do and how it can be customized. But I did come across one shortcoming that I can't believe there's not a package for.
When you want to enter HTML special characters like "   etc. there's no autocomplete. I type & and nothing happens. I've searched and searched for a solution. What am I missing?
Is making a autocomplete file more complicated because I want to see the actual character and insert the code. I've tried encode but it's not what I'm looking for- as I then have to figure out how to type in a weird character Omega, umlaut whatever...
Thanks for any ideas / help
HenryG
 
Posts: 2
Joined: Wed Jul 03, 2013 2:13 am

Re: autocomplete of &... special characters

Postby skuroda on Wed Jul 03, 2013 3:04 am

Some characters are defined as word separators. As such, I don't believe they will trigger completions, even if they do exist. Try creating a syntax specific setting (though you could just make it a user setting if you want). You will modify the "word_separators" entry. The value for this entry will be "./\\()\"'-:,.;<>~!@#$%^*|+=[]{}`~?". I just removed the ampersand from the default settings.
skuroda
 
Posts: 687
Joined: Fri Oct 05, 2012 8:11 am

Re: autocomplete of &... special characters

Postby HenryG on Wed Jul 03, 2013 4:25 am

Thanks. I removed the & from word_separators string in my preferences.sublime-settings file and restarted ST2 as suggested.
Still no autocomplete on &. So I'm guessing by this that all I need now is an autocomplete file that has those definitions in it.
I'm using the coldfusion package. Shouldn't autocomplete for & characters be in an HTML package or somewhere. Thx Again
HenryG
 
Posts: 2
Joined: Wed Jul 03, 2013 2:13 am

Re: autocomplete of &... special characters

Postby Lemon on Wed Jul 03, 2013 10:52 am

You can quite easily create auto complete definitions by yourself by creating files with the .sublime-completions extension in your user packages folder.

While you are in Sublime press Ctrl + Shift + P to bring up the command palette.
Type in "Browse" and you should see an option named "Preferences: Brows Packages".
Press enter on that option and your packages folder should open up in an explorer window.

Now go into the "User" folder and create an "HTML.sublime-completions" file.
It can be called anything really, just as long as it has the ".sublime-completions" extension.

Now copy and paste the following code into the file and save it:

Code: Select all
{
   "scope": "text.html",

   "completions":
   [
      { "trigger": "&aacute;", "contents": "&aacute;" },
      { "trigger": "&Aacute;", "contents": "&Aacute;" },
      { "trigger": "&Acirc;", "contents": "&Acirc;" },
      { "trigger": "&acirc;", "contents": "&acirc;" },
      { "trigger": "&acute;", "contents": "&acute;" },
      { "trigger": "&AElig;", "contents": "&AElig;" },
      { "trigger": "&aelig;", "contents": "&aelig;" },
      { "trigger": "&agrave;", "contents": "&agrave;" },
      { "trigger": "&Agrave;", "contents": "&Agrave;" },
      { "trigger": "&alefsym;", "contents": "&alefsym;" },
      { "trigger": "&Alpha;", "contents": "&Alpha;" },
      { "trigger": "&alpha;", "contents": "&alpha;" },
      { "trigger": "&amp;", "contents": "&amp;" },
      { "trigger": "&and;", "contents": "&and;" },
      { "trigger": "&ang;", "contents": "&ang;" },
      { "trigger": "&apos;", "contents": "&apos;" },
      { "trigger": "&aring;", "contents": "&aring;" },
      { "trigger": "&Aring;", "contents": "&Aring;" },
      { "trigger": "&asymp;", "contents": "&asymp;" },
      { "trigger": "&Atilde;", "contents": "&Atilde;" },
      { "trigger": "&atilde;", "contents": "&atilde;" },
      { "trigger": "&Auml;", "contents": "&Auml;" },
      { "trigger": "&auml;", "contents": "&auml;" },
      { "trigger": "&bdquo;", "contents": "&bdquo;" },
      { "trigger": "&beta;", "contents": "&beta;" },
      { "trigger": "&Beta;", "contents": "&Beta;" },
      { "trigger": "&brvbar;", "contents": "&brvbar;" },
      { "trigger": "&bull;", "contents": "&bull;" },
      { "trigger": "&cap;", "contents": "&cap;" },
      { "trigger": "&ccedil;", "contents": "&ccedil;" },
      { "trigger": "&Ccedil;", "contents": "&Ccedil;" },
      { "trigger": "&cedil;", "contents": "&cedil;" },
      { "trigger": "&cent;", "contents": "&cent;" },
      { "trigger": "&chi;", "contents": "&chi;" },
      { "trigger": "&Chi;", "contents": "&Chi;" },
      { "trigger": "&circ;", "contents": "&circ;" },
      { "trigger": "&clubs;", "contents": "&clubs;" },
      { "trigger": "&cong;", "contents": "&cong;" },
      { "trigger": "&copy;", "contents": "&copy;" },
      { "trigger": "&crarr;", "contents": "&crarr;" },
      { "trigger": "&cup;", "contents": "&cup;" },
      { "trigger": "&curren;", "contents": "&curren;" },
      { "trigger": "&Dagger;", "contents": "&Dagger;" },
      { "trigger": "&dagger;", "contents": "&dagger;" },
      { "trigger": "&darr;", "contents": "&darr;" },
      { "trigger": "&dArr;", "contents": "&dArr;" },
      { "trigger": "&deg;", "contents": "&deg;" },
      { "trigger": "&delta;", "contents": "&delta;" },
      { "trigger": "&Delta;", "contents": "&Delta;" },
      { "trigger": "&diams;", "contents": "&diams;" },
      { "trigger": "&divide;", "contents": "&divide;" },
      { "trigger": "&eacute;", "contents": "&eacute;" },
      { "trigger": "&Eacute;", "contents": "&Eacute;" },
      { "trigger": "&ecirc;", "contents": "&ecirc;" },
      { "trigger": "&Ecirc;", "contents": "&Ecirc;" },
      { "trigger": "&egrave;", "contents": "&egrave;" },
      { "trigger": "&Egrave;", "contents": "&Egrave;" },
      { "trigger": "&empty;", "contents": "&empty;" },
      { "trigger": "&emsp;", "contents": "&emsp;" },
      { "trigger": "&ensp;", "contents": "&ensp;" },
      { "trigger": "&epsilon;", "contents": "&epsilon;" },
      { "trigger": "&Epsilon;", "contents": "&Epsilon;" },
      { "trigger": "&equiv;", "contents": "&equiv;" },
      { "trigger": "&Eta;", "contents": "&Eta;" },
      { "trigger": "&eta;", "contents": "&eta;" },
      { "trigger": "&eth;", "contents": "&eth;" },
      { "trigger": "&ETH;", "contents": "&ETH;" },
      { "trigger": "&euml;", "contents": "&euml;" },
      { "trigger": "&Euml;", "contents": "&Euml;" },
      { "trigger": "&euro;", "contents": "&euro;" },
      { "trigger": "&exist;", "contents": "&exist;" },
      { "trigger": "&fnof;", "contents": "&fnof;" },
      { "trigger": "&forall;", "contents": "&forall;" },
      { "trigger": "&frac12;", "contents": "&frac12;" },
      { "trigger": "&frac14;", "contents": "&frac14;" },
      { "trigger": "&frac34;", "contents": "&frac34;" },
      { "trigger": "&frasl;", "contents": "&frasl;" },
      { "trigger": "&Gamma;", "contents": "&Gamma;" },
      { "trigger": "&gamma;", "contents": "&gamma;" },
      { "trigger": "&ge;", "contents": "&ge;" },
      { "trigger": "&gt;", "contents": "&gt;" },
      { "trigger": "&harr;", "contents": "&harr;" },
      { "trigger": "&hArr;", "contents": "&hArr;" },
      { "trigger": "&hearts;", "contents": "&hearts;" },
      { "trigger": "&hellip;", "contents": "&hellip;" },
      { "trigger": "&Iacute;", "contents": "&Iacute;" },
      { "trigger": "&iacute;", "contents": "&iacute;" },
      { "trigger": "&icirc;", "contents": "&icirc;" },
      { "trigger": "&Icirc;", "contents": "&Icirc;" },
      { "trigger": "&iexcl;", "contents": "&iexcl;" },
      { "trigger": "&Igrave;", "contents": "&Igrave;" },
      { "trigger": "&igrave;", "contents": "&igrave;" },
      { "trigger": "&image;", "contents": "&image;" },
      { "trigger": "&infin;", "contents": "&infin;" },
      { "trigger": "&int;", "contents": "&int;" },
      { "trigger": "&iota;", "contents": "&iota;" },
      { "trigger": "&Iota;", "contents": "&Iota;" },
      { "trigger": "&iquest;", "contents": "&iquest;" },
      { "trigger": "&isin;", "contents": "&isin;" },
      { "trigger": "&Iuml;", "contents": "&Iuml;" },
      { "trigger": "&iuml;", "contents": "&iuml;" },
      { "trigger": "&Kappa;", "contents": "&Kappa;" },
      { "trigger": "&kappa;", "contents": "&kappa;" },
      { "trigger": "&Lambda;", "contents": "&Lambda;" },
      { "trigger": "&lambda;", "contents": "&lambda;" },
      { "trigger": "&lang;", "contents": "&lang;" },
      { "trigger": "&laquo;", "contents": "&laquo;" },
      { "trigger": "&larr;", "contents": "&larr;" },
      { "trigger": "&lArr;", "contents": "&lArr;" },
      { "trigger": "&lceil;", "contents": "&lceil;" },
      { "trigger": "&ldquo;", "contents": "&ldquo;" },
      { "trigger": "&le;", "contents": "&le;" },
      { "trigger": "&lfloor;", "contents": "&lfloor;" },
      { "trigger": "&lowast;", "contents": "&lowast;" },
      { "trigger": "&loz;", "contents": "&loz;" },
      { "trigger": "&lrm;", "contents": "&lrm;" },
      { "trigger": "&lsaquo;", "contents": "&lsaquo;" },
      { "trigger": "&lsquo;", "contents": "&lsquo;" },
      { "trigger": "&lt;", "contents": "&lt;" },
      { "trigger": "&macr;", "contents": "&macr;" },
      { "trigger": "&mdash;", "contents": "&mdash;" },
      { "trigger": "&micro;", "contents": "&micro;" },
      { "trigger": "&middot;", "contents": "&middot;" },
      { "trigger": "&minus;", "contents": "&minus;" },
      { "trigger": "&mu;", "contents": "&mu;" },
      { "trigger": "&Mu;", "contents": "&Mu;" },
      { "trigger": "&nabla;", "contents": "&nabla;" },
      { "trigger": "&nbsp;", "contents": "&nbsp;" },
      { "trigger": "&ndash;", "contents": "&ndash;" },
      { "trigger": "&ne;", "contents": "&ne;" },
      { "trigger": "&ni;", "contents": "&ni;" },
      { "trigger": "&not;", "contents": "&not;" },
      { "trigger": "&notin;", "contents": "&notin;" },
      { "trigger": "&nsub;", "contents": "&nsub;" },
      { "trigger": "&ntilde;", "contents": "&ntilde;" },
      { "trigger": "&Ntilde;", "contents": "&Ntilde;" },
      { "trigger": "&nu;", "contents": "&nu;" },
      { "trigger": "&Nu;", "contents": "&Nu;" },
      { "trigger": "&Oacute;", "contents": "&Oacute;" },
      { "trigger": "&oacute;", "contents": "&oacute;" },
      { "trigger": "&ocirc;", "contents": "&ocirc;" },
      { "trigger": "&Ocirc;", "contents": "&Ocirc;" },
      { "trigger": "&oelig;", "contents": "&oelig;" },
      { "trigger": "&OElig;", "contents": "&OElig;" },
      { "trigger": "&Ograve;", "contents": "&Ograve;" },
      { "trigger": "&ograve;", "contents": "&ograve;" },
      { "trigger": "&oline;", "contents": "&oline;" },
      { "trigger": "&omega;", "contents": "&omega;" },
      { "trigger": "&Omega;", "contents": "&Omega;" },
      { "trigger": "&omicron;", "contents": "&omicron;" },
      { "trigger": "&Omicron;", "contents": "&Omicron;" },
      { "trigger": "&oplus;", "contents": "&oplus;" },
      { "trigger": "&or;", "contents": "&or;" },
      { "trigger": "&ordf;", "contents": "&ordf;" },
      { "trigger": "&ordm;", "contents": "&ordm;" },
      { "trigger": "&Oslash;", "contents": "&Oslash;" },
      { "trigger": "&oslash;", "contents": "&oslash;" },
      { "trigger": "&otilde;", "contents": "&otilde;" },
      { "trigger": "&Otilde;", "contents": "&Otilde;" },
      { "trigger": "&otimes;", "contents": "&otimes;" },
      { "trigger": "&ouml;", "contents": "&ouml;" },
      { "trigger": "&Ouml;", "contents": "&Ouml;" },
      { "trigger": "&para;", "contents": "&para;" },
      { "trigger": "&part;", "contents": "&part;" },
      { "trigger": "&permil;", "contents": "&permil;" },
      { "trigger": "&perp;", "contents": "&perp;" },
      { "trigger": "&Phi;", "contents": "&Phi;" },
      { "trigger": "&phi;", "contents": "&phi;" },
      { "trigger": "&pi;", "contents": "&pi;" },
      { "trigger": "&Pi;", "contents": "&Pi;" },
      { "trigger": "&piv;", "contents": "&piv;" },
      { "trigger": "&plusmn;", "contents": "&plusmn;" },
      { "trigger": "&pound;", "contents": "&pound;" },
      { "trigger": "&prime;", "contents": "&prime;" },
      { "trigger": "&Prime;", "contents": "&Prime;" },
      { "trigger": "&prod;", "contents": "&prod;" },
      { "trigger": "&prop;", "contents": "&prop;" },
      { "trigger": "&Psi;", "contents": "&Psi;" },
      { "trigger": "&psi;", "contents": "&psi;" },
      { "trigger": "&quot;", "contents": "&quot;" },
      { "trigger": "&radic;", "contents": "&radic;" },
      { "trigger": "&rang;", "contents": "&rang;" },
      { "trigger": "&raquo;", "contents": "&raquo;" },
      { "trigger": "&rarr;", "contents": "&rarr;" },
      { "trigger": "&rArr;", "contents": "&rArr;" },
      { "trigger": "&rceil;", "contents": "&rceil;" },
      { "trigger": "&rdquo;", "contents": "&rdquo;" },
      { "trigger": "&real;", "contents": "&real;" },
      { "trigger": "&reg;", "contents": "&reg;" },
      { "trigger": "&rfloor;", "contents": "&rfloor;" },
      { "trigger": "&Rho;", "contents": "&Rho;" },
      { "trigger": "&rho;", "contents": "&rho;" },
      { "trigger": "&rlm;", "contents": "&rlm;" },
      { "trigger": "&rsaquo;", "contents": "&rsaquo;" },
      { "trigger": "&rsquo;", "contents": "&rsquo;" },
      { "trigger": "&sbquo;", "contents": "&sbquo;" },
      { "trigger": "&scaron;", "contents": "&scaron;" },
      { "trigger": "&Scaron;", "contents": "&Scaron;" },
      { "trigger": "&sdot;", "contents": "&sdot;" },
      { "trigger": "&sect;", "contents": "&sect;" },
      { "trigger": "&shy;", "contents": "&shy;" },
      { "trigger": "&Sigma;", "contents": "&Sigma;" },
      { "trigger": "&sigma;", "contents": "&sigma;" },
      { "trigger": "&sigmaf;", "contents": "&sigmaf;" },
      { "trigger": "&sim;", "contents": "&sim;" },
      { "trigger": "&spades;", "contents": "&spades;" },
      { "trigger": "&sub;", "contents": "&sub;" },
      { "trigger": "&sube;", "contents": "&sube;" },
      { "trigger": "&sum;", "contents": "&sum;" },
      { "trigger": "&sup1;", "contents": "&sup1;" },
      { "trigger": "&sup2;", "contents": "&sup2;" },
      { "trigger": "&sup3;", "contents": "&sup3;" },
      { "trigger": "&sup;", "contents": "&sup;" },
      { "trigger": "&supe;", "contents": "&supe;" },
      { "trigger": "&szlig;", "contents": "&szlig;" },
      { "trigger": "&tau;", "contents": "&tau;" },
      { "trigger": "&Tau;", "contents": "&Tau;" },
      { "trigger": "&there4;", "contents": "&there4;" },
      { "trigger": "&Theta;", "contents": "&Theta;" },
      { "trigger": "&theta;", "contents": "&theta;" },
      { "trigger": "&thetasym;", "contents": "&thetasym;" },
      { "trigger": "&thinsp;", "contents": "&thinsp;" },
      { "trigger": "&thorn;", "contents": "&thorn;" },
      { "trigger": "&THORN;", "contents": "&THORN;" },
      { "trigger": "&tilde;", "contents": "&tilde;" },
      { "trigger": "&times;", "contents": "&times;" },
      { "trigger": "&trade;", "contents": "&trade;" },
      { "trigger": "&uacute;", "contents": "&uacute;" },
      { "trigger": "&Uacute;", "contents": "&Uacute;" },
      { "trigger": "&uArr;", "contents": "&uArr;" },
      { "trigger": "&uarr;", "contents": "&uarr;" },
      { "trigger": "&ucirc;", "contents": "&ucirc;" },
      { "trigger": "&Ucirc;", "contents": "&Ucirc;" },
      { "trigger": "&ugrave;", "contents": "&ugrave;" },
      { "trigger": "&Ugrave;", "contents": "&Ugrave;" },
      { "trigger": "&uml;", "contents": "&uml;" },
      { "trigger": "&upsih;", "contents": "&upsih;" },
      { "trigger": "&upsilon;", "contents": "&upsilon;" },
      { "trigger": "&Upsilon;", "contents": "&Upsilon;" },
      { "trigger": "&Uuml;", "contents": "&Uuml;" },
      { "trigger": "&uuml;", "contents": "&uuml;" },
      { "trigger": "&weierp;", "contents": "&weierp;" },
      { "trigger": "&Xi;", "contents": "&Xi;" },
      { "trigger": "&xi;", "contents": "&xi;" },
      { "trigger": "&yacute;", "contents": "&yacute;" },
      { "trigger": "&Yacute;", "contents": "&Yacute;" },
      { "trigger": "&yen;", "contents": "&yen;" },
      { "trigger": "&yuml;", "contents": "&yuml;" },
      { "trigger": "&Yuml;", "contents": "&Yuml;" },
      { "trigger": "&Zeta;", "contents": "&Zeta;" },
      { "trigger": "&zeta;", "contents": "&zeta;" },
      { "trigger": "&zwj;", "contents": "&zwj;" },
      { "trigger": "&zwnj;", "contents": "&zwnj;" }
   ]
}


I got these entities from a list I found and copied from Google, then just put them in the correct JSON format for a .sublime-completions file.
You will need to keep the & character out of your word separator list as stated above otherwise the auto-completions won't work since they start with &.

Now all you need to do is type & and choose the correct auto-completion.
If the auto-completion box doesn't appear, try pressing Ctrl + Space while the caret is immediately after the & sign or whatever you want to complete.

It is possible to define all of these completions without the "trigger" and "contents" parts, but I left them in so you can easily change things if you want.
For example you could remove all of the & and ; signs from the triggers so that "amp" would auto-complete for "&amp;".

That's actually the way I would personally do it since it saves on typing the & sign to start the auto-completion and it means you don't have to mess around with the word separator symbols.
But like I said, I thought I would leave them in so you can change it in any way you want.
Lemon
 
Posts: 27
Joined: Wed Jul 11, 2012 12:49 pm

Re: autocomplete of &... special characters

Postby Blinky on Sat Aug 24, 2013 7:11 pm

Lemon, Thanks for that. Worked perfect
Blinky
 
Posts: 1
Joined: Sat Aug 24, 2013 7:10 pm


Return to General Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 22 guests