When I open Visual Studio Code through Ubuntu PowerShell with "code .", I don’t have instant inline syntax checking while coding. Also all filenames are white:
First connection from PowerShell with command "code ."
The weird thing is that if I click on the lower right corner and I reopen the folder in Windows: Reopening Folder in Windows
then if I reopen it again in WSL, finally I get the filenames colored and the inline syntax check works!
It seems it wasn’t properly connected the first time or something.
How can I properly boot Visual Studio Code with WSL directly with a PowerShell command without having to switch to Windows and then back to WSL?
This is how file c_cpp_properties.json looks:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
2
Answers
Give this a try; install the following extensions:
C/C++ for Visual Studio Code
Code Runner
Note: I guess you have GCC installed already
Your connection to WSL is probably not being properly established.
To ensure that the connection is established properly, you can try launching Visual Studio Code using the code command with the
--remote
option, like this:Using
--remote
will ensure that Visual Studio Code with the WSL instance, and should prevent the connection from breaking as easily. You should see inline syntax checking and colored filenames right away.If you continue to experience issues, you may want to check your Visual Studio Code settings to ensure that they are configured properly for working with WSL. For example, you can try setting the
remote.WSL.useWsl
setting to true to ensure that Visual Studio Code uses WSL as the default terminal.I haven’t used Visual Studio Code like that in quite a while though, so the settings may be different and the
remote.WSL.useWsl
key may not exist anymore. It’s worth trying though.