When save in visual studio code using React it breaks everything
enter image description here
VS Code determines file's language by its extension. In your case, it is javascript, but should be javascriptreact.
Either:
- change all file extensions from .js to .jsx,
- or configure file association settings in your user/workspace settings:
If you have installed JS-CSS-HTML Formatter plug-in effects in your VSCODE, try to remove uninstall it or disable it. Then restart your VSCODE. That's all.
A quick fix is to press on the bottom right side of the screen where it says "JavaScript", a drop-down menu will be opened, type "rea" for "JavaScript React" and press enter.
It works only for the current file, not even for other files in the same project. for a permanent fix, try one of the other answers.
here is how VS Code documentation explains it:
Changing the language for the selected file -
In VS Code, we default the language support for a file based on its filename extension. However, at times you may want to change language modes, to do this click on the language indicator - which is located on the right hand of the Status Bar. This will bring up the Select Language Mode dropdown where you can select another language for the current file.
Tip: You can get the same dropdown by running the Change Language Mode command (Ctrl+K M).
https://code.visualstudio.com/docs/languages/overview
IMHO, I think that isn't an error, rather it's a warning of prettier, because by default prettier in VSC requires an empty line at the end of your code.
Right click -> Format document
Related
I installed Visual Studio 2019 and I want to create a C project.
Not C++ and not C#
There is no option for a C solution
But the doc says VS is both a C and a C++ compiler.
I see no option for a C solution.
There is a doc on the net explaining how to create C project in console from command line. But I want to create a "normal" project.
What should I do ?
I'll summarize what was explained in the video someone linked under your question, as I was able to reproduce the steps and create a working C project in Visual Studio. Kudos to the video creator and kiner_shah for sharing.
As a precondition, you shall be able to create C++ project in VS, so make sure you have the right extensions installed.
Create a new project (Shift+Ctrl+N), select Visual C++ and Console App. This will create a new console app with a default c++ main file. Remove that file and put in a main.c file. This can be compiled, and works just fine.
You should be able to set up the environment by simply adding a ".c" extension to your code.
Additionally, you can manually change your environment by opening your file in VS, clicking on the language displayed at the bottom (which should display "Select Language Mode" and choose C.
C++ can already run C code. So just change the extension from *.c or *.i to *.cpp and it should work. It's not a GUARANTEE, but 95% of the tome it works.
Select File > New > Project, then select C++, Windows, Desktop, then select empty project in the new project menu. Then click on the folder called "Source" and press Ctrl+Shift+A, then in the new item selection, find the box at the bottom of the dialog, then name it .c.
The prefix header functionality in Xcode comes in handy quite often and I was wondering if other IDEs provide a similar functionality? Or is there even a way on compiler level?
I've been looking for this in other environments for quite a time and the only thing I could find were precompiled headers. But that's not really the same as you still need to include the header file in each source file.
So, does anyone know if there's a way to configure prefix headers in IDEs like Visual Studio or QT Creator?
For VC++ you can specify Forced Include File using option /FI on command line or through an IDE. An excerpt from MSDN:
To set this compiler option in the Visual Studio development
environment:
1. Open the project's Property Pages dialog box.
2. Click the C/C++ folder.
3. Click the Advanced property page.
4. Modify the Force Includes property.
For QtCreator you can add two lines to your *.pro file:
CONFIG += precompile_header
PRECOMPILED_HEADER = stdafx.h
Of course, you can type any name instead of "stdafx.h"
I have in my working environment always more then one project open, some of the have same files but are from different project, and finding out which of them are from which project can be a real pain in the ass(however 2 sec over the div and see which folder are they from)
Is there a way to mark them so i can tell which file is from which project?
I am using NB 7.3 64bit for Windows.
There is a plugin which shows the path in the title: http://plugins.netbeans.org/plugin/42000/show-path-in-title
And if you are switching files via CTRL+Tab the path of the selected file is shown on the bottom of the window.
Maybe this helps.
The window title for me is: "{project name} - NetBeans IDE 7.2.1". Directly on the tab I don't know how to put this information, but I use "View -> show versioning labels". Instead of various projects open, I have various "instances" of the same project on different branches in my VCS.
I'm using Ubuntu.
UPDATE
Just reinstalled NetBeans 7.3 on a Windows VM and the behavior is the same: project name prepends "NetBeans IDE {version}" in window Title.
I'm new to Windows development, having messed around in Linux for a while. I need to access console functions and am having trouble getting a comprehensive list of console text attributes off the web. I would like to read wincon.h and windows.h to get the info, but I can't figure out how to get at them. Help please!
Windows does not come with these by default. If you are looking for them, you need to install the Windows SDK and dig around in the %PROGRAMFILES%\Microsoft SDKs\Windows directory.
They're normally stored along with the other SDK headers. Assuming you're using Visual Studio, the easy to look at them is to create a file, add a line to #include the file you care about, right click it, and click on the open document <whatever.h> line in the pop-up menu.
You'll have to install the Windows SDK to get the header files. Windows doesn't come with the software development tools out of the box and depending on which compiler you're using, they might not come with the compiler either.
I would try looking up the console function listing on MSDN
In VS 2008, I used to be able to create a file on the file system (like a .cpp file, for example), and then I could click the refresh button in VS and the file would show up. I have "Show All Files" checked. Note by "create a file on the filesystem" here, I mean like going out to windows explorer and creating a new file, in other words, outside of the IDE.
However, in VS 2010, this doesn't work. I have to close and re-open the solution or it won't see the file, even if I click the refresh button. I realize I can add the file through "Add New Item" and that works fine, but I use the technique above when competing in programming contests, that is, I have a separate tool which creates the file on the file system, and then I can just refresh the file list in VS and see it.
It's not a showstopper, but it's pretty annoying nonetheless. Just wondered if anyone knew a workaround for it. It's a C++ project I'm working with.
EDIT
Also, this problem seems to be isolated to C++ projects, I just tried it with a C# console app and the refresh works ok.
EDIT2
I put an issue for this on the Microsoft connect site. I don't know if it will get any response, but I figured it's worth a shot. Here's the link.
The only time I've ever seen "refresh" do this is in web site projects.. and I found it annoying that it would automatically include stuff ;).
In web apps, which is now the default, you have to click on the Show Hidden Files icon, then right click on the new file and say "include in project"
I put an issue for this on the Microsoft connect site (see EDIT2) in original question for details. MS has acknowledged that they can duplicate the problem, so hopefully they will resolve it in SP1. It does seem to be a bug.