i'm trying to indent my code in visual studio code. I searched and i found that ctrl + F + K should be work, but it doesn't. I tried cmd + k + f too, but it still not working. I hope you can help me!
Indent/format code in Visual Studio code on MAC
How to indent/format a selection of code in VSCode with ctrl+shift+f
I want to indent a specific section of code in VSCode
I read How do you format code in Visual Studio Code (VSCode) post that gives shortcuts to indent the whole code but it doesn't work when selecting a specific section of code.
I tried ctrl+shift+F
after selecting some line in my code but the whole file is indented. I'm on Windows with VSCode Insider 1.8.0. Any help is appreciated.
VSCode nested snippets (or include a snippet inside another snippet)
I'm wondering if I can refer to another snippet within a snippet in VSCode user defined snippet.
Say I have
"Test1": {
"prefix": "snippet_test1",
"body":
"something"
}
and is there a way to insert snippet_test1 in another snippet like
"Test2": {
"prefix": "snippet_test2",
"body":
"${1:snippet_test1}"
}
Now snippet_test2 just outputs snippet_test1
instead of the content of snippet_test1.
cl.exe mylibrary.dll not found, on vs-code?
I want to practice some computer graphics using opengl
. Though, I have visual studio 19 installed, I want to write my code on visual studio code, to learn how the things are done manually.
This is how I setup my project. I downloaded the freeglut 3.0.0 MSVC Package, and copied the folders include
and lib
to my project folder.
I copied this code, for testing if program is compiled correctly.
This is my project folder structure:
.vscode
include
lib
main.cpp // test code
// c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
// tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/I",
"${workspaceFolder}\\include",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"${workspaceFolder}\\lib\\freeglut.lib"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
When I build the project or try to compile from command-line using the command:
cl /I .\include\ .\main.cpp .\lib\freeglut.lib
This is the build output:
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
main.cpp
Microsoft (R) Incremental Linker Version 14.23.28106.4
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
.\lib\freeglut.lib
My problem is that main.exe
is not running.
From command-line, it shows no output.
When opened from file explorer, it gives me the error:
How to change settings input background color in vscode?
I want to change the background color of input in settings. I tried doing "input.background": "#1D1F22"
. But it's not working. Search bar in settings does reflect the new background. However, the any of the input in settings won't change the background color.
Here's my color customization settings (basically I just combined vscode default dark and one dark pro theme):
{
"workbench.colorCustomizations": {
"[Default Dark+]": {
"activityBar.background": "#282c34",
"activityBar.foreground": "#d7dae0",
"activityBarBadge.background": "#4d78cc",
"activityBarBadge.foreground": "#f8fafd",
"badge.background": "#282c34",
"button.background": "#404754",
"debugToolBar.background": "#21252b",
"diffEditor.insertedTextBackground": "#00809b33",
"dropdown.background": "#282c34",
"dropdown.border": "#21252b",
"editor.background": "#20252B",
"editor.foreground": "#D4D4D4",
"editorError.foreground": "#c24038",
"editorIndentGuide.activeBackground": "#c8c8c859",
"editorMarkerNavigation.background": "#21252b",
"editorRuler.foreground": "#abb2bf26",
"editorWarning.foreground": "#d19a66",
"editor.lineHighlightBackground": "#2c313c",
"editor.selectionBackground": "#67769660",
"editor.selectionHighlightBackground": "#ffffff10",
"editor.selectionHighlightBorder": "#ddd",
"editorCursor.background": "#ffffffc9",
"editorCursor.foreground": "#528bff",
"editorBracketMatch.border": "#515a6b",
"editorBracketMatch.background": "#515a6b",
"editor.findMatchBackground": "#42557b",
"editor.findMatchBorder": "#457dff",
"editor.findMatchHighlightBackground": "#6199ff2f",
"editor.wordHighlightBackground": "#d2e0ff2f",
"editor.wordHighlightBorder": "#7f848e",
"editor.wordHighlightStrongBackground": "#abb2bf26",
"editor.wordHighlightStrongBorder": "#7f848e",
"editorGroup.border": "#181a1f",
"editorGroupHeader.tabsBackground": "#21252b",
"editorIndentGuide.background": "#3b4048",
"editorLineNumber.foreground": "#495162",
// "editorActiveLineNumber.activeForeground": "#737984",
"editorWhitespace.foreground": "#3b4048",
"editorHoverWidget.background": "#21252b",
"editorHoverWidget.border": "#181a1f",
"editorSuggestWidget.background": "#21252b",
"editorSuggestWidget.border": "#181a1f",
"editorSuggestWidget.selectedBackground": "#2c313a",
"editorWidget.background": "#21252b",
"focusBorder": "#464646",
"input.background": "#1d1f23",
"list.activeSelectionBackground": "#2c313a",
"list.activeSelectionForeground": "#d7dae0",
"list.focusBackground": "#383e4a",
"list.hoverBackground": "#292d35",
"list.highlightForeground": "#c5c5c5",
"list.inactiveSelectionBackground": "#2c313a",
"list.inactiveSelectionForeground": "#d7dae0",
"list.warningForeground": "#d19a66",
"menu.foreground": "#c8c8c8",
"peekViewEditor.background": "#1b1d23",
"peekViewEditor.matchHighlightBackground": "#29244b",
"peekViewResult.background": "#22262b",
"scrollbarSlider.background": "#4e566660",
"scrollbarSlider.activeBackground": "#747d9180",
"scrollbarSlider.hoverBackground": "#5a637580",
"sideBar.background": "#20252B",
"sideBarSectionHeader.background": "#282c34",
"statusBar.background": "#282c34",
"statusBar.foreground": "#9da5b4",
"statusBarItem.hoverBackground": "#2c313a",
"statusBar.noFolderBackground": "#282c34",
"statusBar.debuggingBackground": "#7e0097",
"statusBar.debuggingBorder": "#66017a",
"statusBar.debuggingForeground": "#ffffff",
"statusBarItem.remoteForeground": "#f8fafd",
"statusBarItem.remoteBackground": "#4d78cc",
"tab.activeBackground": "#282c34",
"tab.activeForeground": "#dcdcdc",
"tab.border": "#181a1f",
"tab.inactiveBackground": "#21252b",
"tab.hoverBackground": "#323842",
"tab.unfocusedHoverBackground": "#323842",
"terminal.foreground": "#c8c8c8",
"terminal.ansiBlack": "#2d3139",
"terminal.ansiBlue": "#61afef",
"terminal.ansiGreen": "#98c379",
"terminal.ansiYellow": "#e5c07b",
"terminal.ansiCyan": "#56b6c2",
"terminal.ansiMagenta": "#c678dd",
"terminal.ansiRed": "#e06c75",
"terminal.ansiWhite": "#d7dae0",
"terminal.ansiBrightBlack": "#7f848e",
"terminal.ansiBrightBlue": "#528bff",
"terminal.ansiBrightGreen": "#98c379",
"terminal.ansiBrightYellow": "#e5c07b",
"terminal.ansiBrightCyan": "#56b6c2",
"terminal.ansiBrightMagenta": "#7e0097",
"terminal.ansiBrightRed": "#f44747",
"terminal.ansiBrightWhite": "#d7dae0",
"titleBar.activeBackground": "#282c34",
"titleBar.activeForeground": "#9da5b4",
"titleBar.inactiveBackground": "#21252b",
"titleBar.inactiveForeground": "#6b717d",
"textLink.foreground": "#61afef",
"sideBar.border": "#282c34",
"breadcrumb.background": "#282c34"
}
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tokenColorCustomizations": {
"[Default Dark+]": {
"comments": "#7f848e",
"textMateRules": [
{
"name": "Comments",
"scope": "comment, punctuation.definition.comment",
"settings": {
"foreground": "#7f848e",
"fontStyle": "italic"
}
},
{
"name": "js/ts italic",
"scope": "entity.other.attribute-name.js,entity.other.attribute-name.ts,entity.other.attribute-name.jsx,entity.other.attribute-name.tsx,variable.parameter,variable.language.super",
"settings": {
"fontStyle": "italic"
}
}
]
}
}
}
How to NOT create obj files when using cl.exe?
I am using cl.exe
in Visual Studio Code
.
I run this command to compile my program:
cl /EHsc program1.cpp
It creates two files:
program1.obj
program1.exe
I do not have any use for the .obj
file, so how to compile directly from .cpp
file to .exe
file?
How can I invoke the breakpoint correctly in VSCode while attach the process?
I created a .net core project with Visual Studio on a local computer.
Now I want to debug it on the server computer(Windows Server 2012R2).
I have to do it like this for the project has used a third-party API which only can work one a formal URL but not localhost.
Therefore, I copy the project to the server computer and use the VSCode to attach the process.
However, when the breakpoint invokes, VSCode reports this error:
Well, on the local computer the project is store in g:\Github\SI-Customservice\SI-Customservice\
, but why it still tries to access the path while on a different computer?
I think there must be a variable saving the path in the project but I can not find it.
And also, I don't want to modify the path I store on the local computer.
How can I solve it? Thank you.
PS: Here is launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
How do I duplicate a line or selection within Visual Studio Code?
Using Microsoft's Visual Studio Code, how do I duplicate a line of code and then move it up and down? (Similar to Sublime's cmd+shift+d behaviour)
It's a feature that I use constantly, and am struggling using Visual Studio Code without it.
Add Custom python.pythonPath to List of Interpreters
I want to use a custom python interpreter, which you can do by adding to python.pythonPath
, as seen in the image below.
However, I thought that there would be an option so that I could add an interpreter to the list of available interpreters that you can see in the below, so that I can easily switch between them, without the need to go rooting around in my user/workspace/folder settings.
Is there any way to add to the list as opposed to using python.pythonPath
to override what is currently shown in the bottom left?
how to fix ImportError: DLL load failed while importing win32api: The specified module could not be found
When i run the following code the error is generate.I had try by install same architecture X64-bit as my operating system and also install X32-bit . But it again gives me a error
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices[0].id)
engine.setProperty('voice',voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
if __name__ == "__main__":
speak("harry is a boy")
Visual Studio Code on macOS + Qt + Intellisense
Visual Studio Code gets the following error:
cannot open source file "QtWidgets/qtwidgetsglobal.h" (dependency of "QApplication")C/C++(1696)
I have a CMake project which compiled and built successfully, but it seems that Intellisense doesn't work.
I have this directory in a path which contains qtwidgetsglobal.h
:
/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework/Headers
And there is another thing:
Directory /usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework
contains directory Headers
and strange executable QtWidgets
I was assumed to include -I/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework
because QtCreator has both
/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework
and
/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework/Headers
but nothing worked.
Actually Visual Studio Code seems to ignore if both directories
/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework
and
/usr/local/Cellar/qt/5.13.1/lib/QtWidgets.framework/Headers
specified.
Any suggestions how to enable Intellisense to work with Visual Studio Code.
Why doesn’t VSCode autocomplete?
Once VSCode autocompletes fine, once it does not complete my text.
I would like VSCode to autocomplete for example if I write an Array, I would like to show the available methods for arrays (JavaScript).
Also can someone tell me what I need to download to autocomplete the JSX tags, too (in React)?
Problem in laravel vscode use wampserver and not xampp
How can I set double-finger horizontal scrolling via touchpad as default in vscode?
That is as a feature automatically enabled, but after a few minutes of horizontal scrolling I somehow get switched so that my horizontal scroll starts going through a single line at the time. How can I be sure that my horizontal scroll will always pan the entire document?
VSCode running Python 2 instead of 3
I am using Python with VSCode, and if I use Cmd+Shift+P and type Run Code, it runs the code with Python2 even though I have specified it to use Python3. I have read this tutorial: How to force VSCode to use Python 3 instead of Python 2? but I do not understand how to change it. (and I can't comment because I don't have enough reputation yay) Could anyone help? Thanks!
Maybe it could be related to the fact that the mini terminal at the bottom runs "python -u " instead of "python3 -u "? Does anyone know how to change that?
Turn off error for console.log on my eslint
I'm trying to turn off lint warning for my eslint at VS code.
My code is contains.
console.log('blabla..');
eslint said as below.
error Unexpected console statement no-console
Even though already add no-restricted-syntax at my .eslintrc.json, no fixed.
Here is my .eslintrc.json
{
"env": {
"es6": true,
"node": true,
"amd": true,
"mocha": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"rules": {
"linebreak-style": [
"error",
"windows"
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name=/^(log|warn|error|info|trace)$/]",
"message": "Unexpected property on console object was called"
}
]
}
}
What did I mistake?
Visual Studio Code: different color themes for different projects
I have 2 Visual Studio Code instances with two different projects.
Is there a way to make VS Code instances' themes different from each other depending on the project?
Where is the option to allow old RegEx logic? [duplicate]
This question already has an answer here:
I am not good with RegEx but i was doing good with semi-complex expression combinations while using http://buildregex.com/
However these expressions like this simple example: (?:b_)(?:.*)(?:\ \=\ \{)
(which would find stuff like b_somename = {
)
are not working anymore and im curious if there is an option or settings.json entry to use the old logic without a rollback.
Thanks in advance
How to create a workspace
How do we create a workspace in Visual Studio Code? I see File menu command to open, add a folder to and save a workspace but nothing to create one.
The questions How to create workspace in VS code and How to Create a VSCode Python Workspace? are specific to Python. I am asking how to create a generic workspace.
The question What is a 'workspace' in VS Code? provides some explanation of what they are but it is not clear how to create them.
Trying to use emmet with a react app in vs code
I am using Visual Studio Code and creating a React App. I understand that Vsc comes with Emmet but it does not work with my React App. I have tried putting the following code in settings.
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"xml": {
"attr_quotes": "single"
}
},
"emmet.triggerExpansionOnTab": true,