Is there a way to add a dictionary to Sublime text and enable predictive typing using it? - sublimetext3

I want the editor to suggest words to me as I type. It does this currently to the words that are already present in the editor. But I want it to suggest from a standard dictionary.
Is there any way to do this?

You can write a completions file. Just insert all words you want to complete into the completions list. Select Preferences > Browse Packages... and open the folder User, there you create a file with the extension .sublime-completions, e.g. MyWords.sublime-completions with the content:
{
"scope": "text", // <- your language scope here, press ctrl+alt+shift+p
"completions":
[
"hello",
"world",
"foo",
"bar",
]
}

I don't know about the Sublime text editor but Atom supports this functionality.
You can download the atom from here.
BTW Atom is free of cost rather than sublime. Both have same functionality. But to execute program you can use command line to execute.
Here is the link for Atom https://atom.io/
and here is the link for the autocomplete package for English : https://atom.io/packages/autocomplete-en-en
Hope this may helps you.
Go through the images provided in the Second link.

Related

Can sublime 3.0 convert display from plain text to source color scheme automatically?

I'm little new to Sublime, wanted to know if there is a way to change display in sublime-3.0 from plain text to source colors automatically (i.e. Sublime should keep source colring from where code was copied and pasted like- HTML or XML or Java code) without I changing it manually.
Thanks in Advance!
Sublime Text already does this for some languages, like XML.
It works when you have a blank document that is set to Plain Text format (i.e. you open a new tab), and paste something in whose first line can be identified to be a specific language, using regular expressions.
For XML, it looks for an XML prolog or an XML element with a namespace. Regex
For HTML, it looks for a HTML doctype.
It currently doesn't support Java - I guess it's not easy to come up with a regex that would match only the first line of a Java file and not a C# file, for example. If you do have some ideas, you can use https://packagecontrol.io/packages/PackageResourceViewer to edit the relevant .sublime-syntax (YAML) file and add a first_line_match in.
You may also find the following packages helpful:
https://packagecontrol.io/packages/AutoSetSyntax
https://packagecontrol.io/packages/ApplySyntax
Extra note: these "first line matches" also apply when opening files that aren't automatically matched to a syntax by the file's name/extension.
There might be a better way, but I've done it with the Package control ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X). Search for Package Control: install Package, press Enter and then search whatever package you need.
After installing the SCSS package, I'd get the HTML colouring as well.

How to make Sublime Text not autocomplete element names within text elements

When I write HTML in Sublime Text 3, I like having autocompletion of attributes and element names and so on, but Sublime Text is always over-predicting things and turning my text content into elements (inappropriately), when the vast majority of the document body I am writing is text, not elements. What gets really annoying is if I press Enter at the end of a line where it believes the word I am typing is a typo of a different element, I get some really frustrating behavior:
The workaround I see is to press EscEnter at the end of every line but that isn't particularly ergonomic (and I have severe RSI so I'd rather have things be ergonomic).
Here are the relevant portions of my Preferences.sublime-settings:
{
"auto_complete": false,
"auto_complete_selector": "source - (comment, string.quoted)",
"tab_completion": false,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}
I have looked at the Sublime Text documentation regarding completions and snippets but it isn't obvious to me how to suppress completions entirely during a text context. I don't currently have any HTML-mode-specific options configured.
Sublime's HTML autocompletions are implemented in a Python script.
It is possible to edit it, such that HTML tags will only be offered when you type < and a letter - instead of offering them while typing "plain" text content inside HTML.
To do this:
Install PackageResourceViewer using Package Control (if it isn't already installed)
From the Command Palette, type PRV: O and select PackageResourceViewer: Open Resource
Select HTML
Select html_completions.py
Find the line # if the opening < is not here insert that (https://github.com/sublimehq/Packages/blob/77867ed8000601962fec21a012f42b789c42195b/HTML/html_completions.py#L243)
Change completion_list = [(pair[0], '<' + pair[1]) for pair in completion_list] to completion_list = []
Save the file
Note that this creates a file that will override the version that comes with ST, so when a new build of ST3 is released, your version will still be used. In case this file is ever updated, it might be a good idea to delete your version to ensure you have the latest changes, and then to re-apply the above steps (if necessary - maybe it will be "fixed" in a future update to not suggest anything when auto_complete is set to false). To do this:
Tools -> Browse Packages
HTML
Delete html_completions.py

Override the default tab autocomplete content in Sublime Text 3

What's the correct way to override the JavaScript "fun" tab completion for example?
I've created a new file in my user package called: my.sublime-completions and I understand that file requires two properties (scope & completions)?
Thanks in advance for the help :)
The documentation on completions and the two See Also links at the top should provide plenty of detail on how to structure your .sublime-completions file for use in JavaScript. For example, the following exactly replicates the default snippet (use \n for newlines and \t for tabs, if needed):
{
"scope": "source.js",
"completions":
[
{ "trigger": "fun", "contents": "function ${1:function_name} (${2:argument}) {\n ${0:// body...}\n}" }
]
}
The easiest way to override the default fun JavaScript snippet is to first install the PackageResourceViewer plugin via Package Control. Once that's set up, restart Sublime and open the Command Palette with ⌘⇧P (OS X) or CtrlShiftP (Windows/Linux). Type prv to bring up the PackageResourceViewer options, and choose PackageResourceViewer: Open Resource. Scroll down the list and select JavaScript, then open the function-(fun).sublime-snippet file, using XML for syntax highlighting if you wish. If you are using a more recent version of Sublime, the file may be located under JavaScript/Snippets.
Next, set the contents of the file to the following:
<snippet>
<content><![CDATA[]]></content>
<tabTrigger>fun</tabTrigger>
<scope>source.js</scope>
<description>Don't Use</description>
</snippet>
Save the file, and you should be all set. Assuming your .sublime-completions file is set up correctly, when you type fun in a JS file you should only see your completion, not the default one.
Good luck!

Prevent Sublime Text 3 from tab completing 'sup' to '<sup>' in a non-HTML file

When I type sup then TAB in Sublime Text 3, I get <sup>. That isn't what I want; I only want tab completions based on what is in my current file.
How can I limit tag style tag-completions to just HTML files?
I was hoping to find a setting called tag_complete_file_extensions or similar.
I don't currently understand the implications of these default preference settings, but they don't look like what I want:
{
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
// Additional situations to trigger auto complete
"auto_complete_triggers": [ {"selector": "text.html", "characters": "<"} ],
}
At the least, I'd appreciate an answer pointing me in the right direction. I don't mind forking a package or writing some custom code.
I believe this behaviour is provided by the Emmet (formerly ZenCoding), or similar package and not sublime directly.
Are you sure syntax is set accordingly for the files you get html tag completion?
By default Emmet detects that you are working on html files and enables tag completion (in my case I did not have to configure anything to get this functionality). You should have a closer look at your packages and your configuration and possibly update existing ones.
If you need any further help with the configuration files, I'm happy to help!
Cheers!

Looking for a package for sublime like task list in notepad++?

The package should work as:
I specify a word
The package open a (dock) window, show all lines in the source file that have the word.
I could use the lines in dock window to jump between the source file.
Thank you!
Not really sure what the task list in notepad++ is like, but it sounds like you want something to search for TODO entries. Take a look at https://github.com/robcowie/SublimeTODO. Though assuming your tagging is accurate, you are using ST3, and this plugin has not been ported. If that is true, you may want to check out https://github.com/dnatag/SublimeTODO, which is supposed to provide the ST3 compatibility. Note I haven't tested it, but based on some of the comments in the pull request, it seems like it might work.

Resources