Sublime Text: ignore double quotes and display correct colors for HTML tags - sublimetext3

I used to write HTML attribute values without double quotes. That makes the HTML code look very clean. Take my another answer as an example.
However, such a style causes Sublime to display tag colors incorrectly. In the following picture, since <div id=wrapper> has no double quotes around wrapper, Sublime does not show any color after that line (but how come everything looks OK before that line?).
Is there any way that I can set Sublime to ignore the double quotes and display correct colors?

What you need to do is redefine the syntax definitions in Sublime Text. You can also do this on the user level. Two great resources for doing this are here and here. They're very well written.
With that said, I’m using build 3083 right now and I can’t replicate your issue. A quick update might be all you need. I hope this helps.

Sublime Text has a setting called "HTML/XML Attributes" that can be customized to handle this scenario. You can add the following setting to your Sublime Text user settings file to ignore the double quotes:
Json
"auto_complete_html_attributes": false
This setting will turn off auto-completion for HTML/XML attributes in Sublime Text and allow the display of tag colors correctly. To access the user settings file, go to Preferences > Settings.

Related

Is there any shortcut-key in sublime text 3 to change language?

Actually there is an easy way to change language in Sublime Text 3, that's on the bottom right corner. But I need the fast way to change while my hands are on the keyboard. Is there any shortcut-key to change language in Sublime Text 3?
Thank you.
All of the non-hidden syntaxes in Sublime are automatically added to the View > Syntax main menu, which is the same menu that appears when you click on the file type in the bottom of the window. Additionally all syntaxes are added to the Command Palette as commands that start with Set Syntax:.
So the easiest and fastest non-mouse way to swap the syntax on a file is to open the command palette an enter just enough filter text to find and select the command that will swap to your desired syntax, such as in the image below to switch to HTML.
Sublime remembers what command you select for any given command palette input, so for extra speed you can use filter text like sh and manually select the Set Syntax: HTML command that appears to tell Sublime that's the command you want. Now whenever you enter sh it will automatically select that command for you by default.
The set_setting command can be used to set any setting, including the syntax setting, so you could also bind a key to that command to switch easily to an often used syntax. However that requires that you know the full package resource name of the syntax in question and it will not properly set up the syntax specific settings (that requires a plugin that uses view.assign_syntax()).
There may be a package available on package control that provides such a command already, but I'm not aware of any offhand.

Change color of tab characters in Sublime Text 3 theme

I am using the Fortran text highlighting package for ST3, and I am making a theme using this fantastic homepage.
But see the image below. Where there are tab characters within the code (not indentation), those are colored in pink. How can I change that color, or remove it?
In the preferences, default file settings you get this instruction for changing the width and color of indent guides.
// Set to false to turn off the indentation guides.
// The color and width of the indent guides may be customized by editing
// the corresponding .tmTheme file, and specifying the colors "guide",
// "activeGuide" and "stackGuide"
"draw_indent_guides": true,
With some trial and error I found that the property is indeed a variable on this page and it's called Invalid. That is also the name in the .tmTheme file. But on the site there are no such characters in the sample code (that I saw) and the name isn't obviously related to the tab characters in my code.
The pink was in fact the default Invalid color on the theme editor site.
You are supposed to remove those, since they are not supposed to be there. They are referenced as Invalid token which can show signs for deprecation, unreadable code etc. It is supposed to look like:
diff = first - second
and not
diff = first - second
If you really want to overwrite that, you can edit the syntax definition file or overwrite it in your User folder.
Go to Preferences -> Browse Packages -> Fortran -> grammars
Open FortranModern.sublime-syntax or FortranFixedForm.sublime-syntax
Remove the following lines
# tabs are illegal
- match: \t
scope: invalid.illegal.tab.fortran
Done?
PS: A pull request to fix this has already been merged so next builds should be fine

How to display a text file (.txt) as a code file with color in Sublime Text 3

I'm using sublime text 3. And I want to display a text with color like a code file in Sublime. But I don't know how to do. Please help me!.
Thanks you!
You can manually set the syntax of any file using the Command Palette and type "Set Syntax: " or from the bottom right dialog (by default it reads "Plain Text").
If you want Sublime Text to remember your choice, you can also do that from the syntax selection dialog mentioned above, or View > Syntax > Open all with current extension as…".
I think if you need your text file for purposes like note taking, there is a nice hack.
Go to View > Syntax and then select haskell. Haskell syntax highlighting is subtle and works fine. To highlight something just capitalise the first letter and it pops in a different colour. Numbers are highlighted in a different colour again, increasing readability. Finally brackets commas etc have different colour which further helps.
Well, coloring is based on the syntax, like every programming language has its syntax, but the pure text file is hard to detect the syntax since it can be anything. So if you use the Sublime to coding,try save it as a file with file extension first, then the Sublime will detect by itself, however you could also do this manually.
The ability to create your own syntax highlighting rules is one of the excellent features of SublimeText.
Have a look here at some other people wanting to build their own syntax highlighting rules:
How to not highlight object keys such as 'do'/'package' as keywords in Sublime?
Sublime Text - C++ Highlight
That explains the basic tools you need to use to do what you want to do.
Following the same ideas there you can build a syntax highlighting scheme for whatever it is you want to achieve in your text file based on whatever syntax rules you are trying to follow. Hard to imagine what those are for a text file without you supplying exact details but if you want to do it Sublime Text gives you the power to do it.
If you give that a try and have trouble with developing the relevant Regular Expression/s to do what you want to do then post what you have done and how it is not working the way you hoped and perhaps we can help you get to the end of the game.

How to highlight variables in sublime?

How to highlight variables in sublime text 3? like in netbeans
Your question is not very clear, but here are some options. First, if you're just trying to get variables highlighted differently, you'll need a color scheme with more options than the default Monokai. There are many available on Package Control, but one in particular that I know will work (since I'm its author) is Neon:
You can use the excellent tmTheme Editor to see how this or hundreds of other themes will look (sort of) in different languages. (I say "sort of" because the highlighting engine used on the website is different than the one in Sublime, so there will be some differences. Overall it's pretty good, though.)
On the other hand, if you're trying to highlight all the instances of the $page variable, you'll have to do two things. First, double-click on $page to select it. Then, select Find -> Quick Find All (or use its keyboard shortcut) to select all the instances of $page in the document:
The gutter icons and colored underlines are from the BracketHighlighter plugin
Unfortunately, this is the only way to get this to work when using PHP and other languages like JavaScript that denote variables with a $ or other symbol. If we were to use Python, for example, you could just double-click on page and it would look like so:
As you can see, all the other instances of page have boxes around them. This behavior is hard-coded into Sublime, so while it can be turned on and off, it can't be modified or told to recognize other characters in any way.
Good luck!

Which Notepad++ plugin is highlighting my HTML colors?

I have a plugin that I installed that does this:
I really like this function (highlighting HTML colors) but I don't know plugin does it. I want to put it on the another copy of Notepad++ but installing plugins is a rather big thing and I don't want to have to install them all - it gets cumbersome.
Does anyone know which plugin highlights my colors?
It's a wonderful feature.
I think that you are referring to the HTML Color plugin. You can find it here
http://npp.campulka.net/
I think that feature was taken out of Notepad++ due to the users' inability to read the text at times if the colors were too overwhelming. Instead, I recommend trying to install the Quick Color Picker or HTML Color plugins. They are about as close as you're going to get:
Quick Color Picker: https://code.google.com/p/nppqcp/
HTML Color: http://npp.campulka.net/
Source: Notepad++ hover preview on link or color?
Check Quick Color Picker for Notepad++.
The plugin puts the colored underline under the color code based on it's value and thus is not obtrusive in reading the text.
I'm using it without any issues with the Notepad++ v6.9.2
I just ran into this and resolved it as follows:
Download and install the UDL file found at https://github.com/notepad-plus-plus/userDefinedLanguages (get the zip file with all languages). Instructions for installation are on that page. Close Notepad++ and reopen, then go in your Notepad++ menu to "Language". You should now see a long alphabet list with subcategories off to the right indicated by an > Go to H then click on the > and select HTML with your HTML file open in Notepad++ The moment you do that, all your HTML syntax will (should!) be highlighted.

Resources