Sublime Text 3: How do I stop flagrantly incorrect tab suggestions? - html

Where in my settings is autocomplete failing to decipher what it's suggesting? This is obviously syntactically incorrect, I'm inside the quotes for a tag and it's suggesting more tags.
Example:

This is due to the way Sublime Text scopes work. Autocompletion is based on the scope of the character immediately to the right of the caret when there is no selection. In your example, it is the " character. It therefore doesn't see that the caret is actually inside the style attribute, because it sees CSS as only what is between the quotes, and not the quotes themselves. Therefore, it suggests other attribute names.
The workaround is simply to ensure there is a space between where you are typing and the closing " character of the attribute value.
EDIT: I have now suggested a fix for this in a PR to the SublimeText Default Packages repo. If it gets accepted, it will be available in the next ST3 build. Alternatively, you can follow the instructions in the repo's Readme to grab the changes sooner.
EDIT: and another PR to make the same fix when typing just before the </style> tag.

Related

Sublime Text: Accept Suggested Autocomplete Without Expanding it

In Sublime Text, I have installed Emmet so that I can do zen coding. Now, the problem is that when I'm typing, and get an autocomplete suggestion, as soon as I accept that autocomplete suggestion (either by entering tab, enter, or even pressing space bar), the suggested tag is expanded; this causes me not to be able to continue the zen coding.
To give you an example, say I want to insert a <select> with 6 <option> child elements. If I enter select>opt, then autocomplete suggests option, but as soon as I accept option, that expands to select<option></option>.
What I want is to accept option, but that it won't expand to <option></option>.
Is there anyway to accomplish this?
Actually, the answer is very simple. In your example, when you get the autocomplete suggestions for option, you will get 2 of them. One is the tag, the other is text. Use Ctrl+Space to go through all the suggestions, and select the text version of option and not the tag version.
In Sublime Text completions consists of a 2-tuple containing the showed string and the inserted characters/snippet. I don't think know whether it is possible to just insert the showed string. However if you search for any way, there is a way to establish: modify the source code of the html tag completion file.
Install PackageResourceViewer, then press ctrl+shift+p write PackageResourceViewer: Open Resource. Select HTML >>> html_completions.py.
If you save the file it will shadow (not overwrite) the original completions file. Hence just remove it to get the original behavior.
In this file:
in line 15 replace return (tag + '\tTag', tag + '>$0</' + tag) by return (tag + '\tTag', tag).
in line 245 replace completion_list = [(pair[0], '<' + pair[1]) for pair in completion_list] by completion_list = [(pair[0], pair[1]) for pair in completion_list]
Now it should insert the tag names instead of the whole tags.

Automatically unindent closing HTML tags in PyCharm

I have toggled every option that seems to make sense and have searched for an hour, but I can't find a solution. I'm sure I'm just missing some magic word, and the solution is probably simple, but how do you make PyCharm automatically unindent closing HTML tags?
For example, if I type:
<div>
Test
</
PyCharm will automatically fill in the div>, but it will leave the indent hanging.
Thanks in advance.
Update: Part of the reason why I was particularly annoyed by this problem was that I was unable to backspace to the appropriate indent level before typing the closing tag, so to put the tag on the correct level, I had to Shift+Tab or press Home then Backspace.
I found this answer that pointed me to Settings -> Editor -> General -> Smart Keys, where I set Backspace -> Unindent to To nearest indent position, instead of To proper indent position, which dramatically reduced the annoyance level of the original issue.
I'll leave this open, as automatically unindenting closing tags (or automatically setting them to the "proper indent position") would still be the most ideal solution.
PyCharm automatically adds the closing tag when you type the starting tag. So when i type <div> there will be </div> directly added.

How to stop PyCharm from autocompleting HTML and Django template tags?

When I'm writing Django templates with PyCharm it automatically closes them; this is reasonably helpful when I'm starting a new tag, but if my intention is to place some already existing content inside a different tag it tends to get a bit annoying, as I then have to delete or move the closing tag, e.g. I'll end up with something like this.
<div></div>Already existing text.
Is there any way of disabling this feature?
You can modify the smart keys functionality of the Editor by doing the following:
Go to Settings --> Editor --> General --> Smart Keys
Uncheck "insert closing tag on tag completion" under the "XML/HTML" section.
Apprently, there is a way to achieve this already in PyCharm.
Select the desired code fragment.
Do one of the following:
On the main menu, choose Code | Surround With
Press Ctrl+Alt+T
A pop-up window displays the list of enclosing statements according to the context.
Select the desired surround statement from the list. To do that, use the mouse cursor, up and down arrow keys, or a shortcut key displayed next to each element of the list.
Here is the relevant documentation for Wrapping
Here is the documentation for unwrapping
EDIT:
The Shortcut for Tags is Ctrl+Alt+J
Here is the relevant documentation for tags

Netbeans disabling code completion in HTML for quote marks

In the Netbeans (v 7.01) code complete options I have disabled:
All Languages -> Insert Closing Brackets Automatically
Html -> Equals sign (=) Keypress After Attribute Name Autocompletes Quote Set
Html -> Quote mark (") Keypress After Attribute Name Autocompletes Closing Quote
and yet if I type out the following html line:
<div class = "">
Netbeans corrects this to:
<div class = """>
So in other words, the IDE adds in an extra quote mark. The problem doesn't seem to happen in PHP scripts, only HTML. But I'm finding it extremely infuriating and I can't figure out how to stop it!
Anyone have any idea what's going on?
This is a bug in NetBeans. Bug 224340 HTML auto-completion adds extra quote on properties was opened on it. Please update the bug with any additional comments.
EDIT:
Added a video on Vimeo demonstrating the behavior. BUG#224340 NetBeans 7.2.1 HTML auto-completion adds extra quote on properties

<p> tag getting added to inline macro

I am using umbraco 4.7. I have created a razor macro to insert telephone number in my rich text editor. Whenever i add the macro in the RTE, <p> tags are added around the macro automatically. I tried removing the extra <p> tags by editing the html but as soon as I click on save, the <p> tags are added again. I tried installing this package
but it didn't solve my problem. I have tried setting the <TidyEditorContent>False</TidyEditorContent> and checking the forced_root_block : 'p' but none of these could solve the problem.
Any pointers to solve this issue?
This is a common issue, and the RTE causes a number of headaches for maintaining the integrity of your web page. The whole "should we include paragraph tags or not?" question is a difficult one, as it is fine to remove them when only inserting a single paragraph of text, but what if the content editor decides to add more, and you are stripping out the first and last P tags?
Bearing in mind that the CSS for a site will always need to support whatever you choose, the best option is to edit the configuration file to make TinyMCE omit the P tags. To do this, you need to edit the /config/tinyMceConfig.config file. This has two interesting sections at the bottom. contains allowed HTML tags, and the of course contains the opposite.
If you look in the valid elements list of comma separated values, you should see a value #p[id|style|dir|class|align]. Taking note of EXACTLY how this is formatted, you should be able to move it into the invalid elements section. Put it after the default font tag, with a comma preceding it of course.
Restart IIS and try entering your content in the RTE. When you publish, then view the output, you should see that the string in the RTE has had the paragraph tags stripped.
One final option is to strip the paragraph tags from the output. There are many new ways of doing this, but for your Razor version I would use something like:
#Html.Raw(umbraco.library.RemoveFirstParagraphTag(value.ToString()))
This idea is covered in another StackOverflow article.
Good luck, and please let us know if you have any success.
use this jquery .....
$('p').each(function() {
var $this = $(this);
if($this.html().replace(/\s| /g, '').length == 0)
$this.remove();
});