Why does VS Code default to 2-space indents? - tabs

I don't know how many projects I've seen with this kind-of-hard-to-read formatting, and I'm not finding the answer online as to why Microsoft made 2-space indents a default, but to me it's kind of ruining projects until I figure out how to get VS Code or other editors to display 2-space indents as 4-spaces or 4-column tabs (but still save to 2-space indents).
Does anyone know why VS Code was set to default to this? Also any advice on how to config the editor to display the indents as 4-column tabs while still saving as 2-space indents would be great.

click this you will have all the options.

I did it by changing the option "Tab Size" to 4 and unchecking the option "Detect Indentention"

Related

VS Code isn't recognizing html files

VS had suddenly stopped recognizing HTML files and it doesn't autocomplete tags or even show the syntax unless I manually input every single file name in it, I would really appreciate the help on any idea how to solve that Here is how it looks:
I have tried many things but nothing seems to work or help fix it
See if this solves the problem:
On the bottom right of the application, you should see something like this:
Click on the "Plain text".
Search HTML in the list and click it.
Then your HTML should turn colorful.

how do I search within a CSS file for specific class in Visual Studio Code?

I am using a bootstrap template for a webpage. I want to customise certain parts of it, but I am struggling to find the CSS rules that relate to the HTML classes because the .css file is so large!
All I can find when searching the web for a solution is ways to search for files rather than within them. It looks as if there was an extension that may have worked, but it doesn't seem to exist any longer.
any help would be hugely appreciated.
You can search over files in VS Code using CTRL/SHIFT/F, more info here
This is from the website:
VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location. Expand a file to see a preview of all of the hits within that file. Then single-click on one of the hits to view it in the editor.
The simplest way to "find the CSS rules that relate to the HTML classes" is still to open your template/website in a browser -> right click the page and "Inspect Element" -> Find the HTML you need to inspect -> You'll have all the CSS classes and rules involved into styling it ...in the sub-tab "Styles".
simple just "ctrl+f" and type whatever you want to search inside text box show on top right corner.

Sublime Text 2 Tab Auto-Complete

I have mostly worked in Adobe Dreamweaver (don't hate too much, I really like some of its feature that I'm about to mention). I'd really like to become proficient in Sublime Text 2. There are two things I'm looking to figure out:
When I start typing a tag and it auto suggests what it thinks I'm typing, I can hit tab or enter to auto-complete the tag. But when I do this, it makes the closing tag too. I hate this, because I go back to change things often, then when I tab to auto complete, it adds in the entire closing tag. So my question is can I make it ONLY auto-complete the opening tag when I hit tab or enter? (btw, I have emmet installed too)
My next question, if anyone is familiar with Dreamweaver, whenever I open an HTML file, it opens all corresponding files in a sub menu below the tab. So I open say, index.html, and below it appears, automatically, my css file, js file, and any files that I've put in the html file. With Sublime Text, I have to go to the trouble to open all those files with it. Is there any plugin or way to make Sublime replicate this?
Thanks so much for any help anyone can provide!
This is a bit old, and maybe you've discovered the answer, but for #1, you can set the "auto_complete_commit_on_tab" setting to true in your user settings.
http://www.sublimetext.com/docs/2/auto_complete.html

Color Scheme for code not working - Sublime Text 2

Sometimes Sublime Text 2 will recognize my code with its color scheme and other times it won't. I do a lot of pasting code into the code editor and editing it, but I rarely write code in it, mostly editing my older code. Its really helpful having the color scheme!
You can also set the coding language by clicking the bottom right corner "Plain Text" to open a list of languages to choose from. Click the relevant language and the Sublime will do the coloring according to your selection.
If you are just opening new files and pasting text in, the default syntax is "Plain Text", thus no highlighting. You can set the syntax in the buffer by opening the command palette and searching for "Set Syntax: ". If that isn't what is happening, please try to give more information.
-skuroda
Go to a color page and copy just the < ? and php from the top. Go to the white text page and highlight/paste.
This worked for me. i had a problem with Arduino color coding but now i solved that with the help of this trick. You can also set the coding language by clicking the bottom right corner "Plain Text" to open a list of languages to choose from. Click the relevant language and the Sublime will do the coloring according to your selection.
Javascript Syntax was not working for me, so changed to Java. Color shading appeared.

Fix formatting of aspx file in Visual Studio?

I have a file with a lot of this kind of thing in it:
<asp:TableCell ID="TableCell9" runat="server">Company
Organization:</asp:TableCell><asp:TableCell ID="TableCell10" runat="server">
How can I get the formatter to change it to shows like this:
<asp:TableCell ID="TableCell9" runat="server">Company Organization:</asp:TableCell>
<asp:TableCell ID="TableCell10" runat="server">
What I have tried:
I opened Tools->Options then browsed to Text Editor. I got a list of Languages. I selected HTML because that is the language that controls formatting for aspx files.
I changed "tag wrapping" to not have "Wrap tags when exceeding specified length" checked.
I then pressed ctrl+k, ctrl+d (Format the document). This did not fix the problem.
What I don't want to have to do:
Edit the file manually to fix all the tags.
Any ideas?
I was having the same problem, and I found the answer on Scott Gu's blog.
The solution is to setup the formatting rules in Visual Studio (right click on any tag, click on Formatting and Validation, click on Tag Specific Options)
When press ctrl-k, ctrl-d the document will format as per your settings. If a closing tag does not move to a new line, it's because there is no space between the end tag and what is preceding it. This happens because Visual Studio is being careful to not change how the page is rendered.
For the full blog post checkout Scott Gu's blog post.
http://weblogs.asp.net/scottgu/archive/2006/07/07/Tip_2F00_Trick_3A00_-Custom-formatting-HTML-in-Visual-Web-Developer-and-Visual-Studio-2005.aspx
I found a way that works.
In the list with HTML there is a File Extension Option.
I added ASPX to that list and said to edit it with an XML editor (I suppose I could have just right clicked it and opened it with the xml editor, but I did not think of that till after).
Anyway, once it is open as an XML File I formatted it (ctrl+k, ctrl+d) and it formated the way I wanted it. I then removed the extension mapping and reopend the file again.
One last formatting adjusted the tab spacing and I was perfect!
Note: When I did this the top line had this change made: from Page Language="C#" to Page="" Language="C#" I changed it back manually and all seemed to be well.
Later Note: Sadly, Visual Studio messes up the formatting every time I run the solution. Note that pressing ctrl+k, ctrl+d is fine and keeps my nice formatting, but when I run, Visual Studio collapses it down to a very unreadable format. :( Don't know how to fix it....
The answer should be:
Tools-Options->Text Editor->HTML-Format->Tag Specific Options
Then in ASP.NET Controls look for your tag. If it's not there you might need to Add it (New Tag) and set the Line breaks as you want them.
However I've found that this does not always work.Visual Studio respects the per tag colorization but Line breaks are not always respected.
So if this doesn't work for you, you might need to do a Search-Replace hack (Look for and replace with a NewLine in the middle), thenk try Format document and that should work.