Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all 98612 articles
Browse latest View live

How can I prevent VS Code to revert my changes on save?

$
0
0

I have a file open in VS Code

enter image description here

As you can see on line 1, 5, and 6, there are errors.

When I hovered over them, I saw this message.

enter image description here

Then, I decided to fix them base on the error message suggested.

enter image description here

Now, the 3 errors are gone. BUT as soon as I hit save.

Those errors are coming back. My changes seem to be reverted.


I have this set in my settings.json

"editor.formatOnSave": true

Any suggestions on how can I prevent this behavior?


Permanently resolve Unable to watch for file changes in this large workspace

$
0
0

To resolve this issue I got there to the link provided by vscode

https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

Ok, this, corrects the error, But when I restart the Linux and again open my React project, I get the Same error. max_user_watches file again gets the value of 8192 as no. of max files.

My react server is not starting due to this issue.

Then I again follow the same step of the link provided, this sometimes gets frustrating.

Any permanent Help I could get from you.

How to integrate guru with visual studio code?

does visual studio code with PlatformIO requires CLang?

$
0
0

I am working on a project for esp32 board. I am using Visual Studio Code with PlatformIO as an IDE (with Arduino framework) for code development.

I need to use static code analyzer "CLang" for my current project. Please inform, do I need to require CLang to be installed externally or how to configure it with PlatformIO for static code analyses.

I have followed below link but it says CLang is require if you use ATOM, but no information is available regarding how to use it with PlatformIO.

Link: https://alselectro.wordpress.com/tag/vs-code-with-platform-io/

Please help, Thank you in advance....

How to pass VM arguments in VSCode?

$
0
0

I am trying to mock a static method using JMockit. The combination that I'm trying to run is Junit5, Jmockit 1.41 and JDK11 with VSCode. Initially I got java.lang.IllegalStateException: Running on JDK 9 requires -javaagent:<proper path>/jmockit-1.n.jar or -Djdk.attach.allowAttachSelf while running it on STS. I solved this problem by passing -Djdk.attach.allowAttachSelf as vm argument in STS. This works fine with STS.

However, when I try to run the same source code in VSCode, it threw the same error java.lang.IllegalStateException: Running on JDK 9 requires -javaagent:<proper path>/jmockit-1.n.jar or -Djdk.attach.allowAttachSelf. So I edited java.jdt.ls.vmargs key and added -Djdk.attach.allowAttachSelf as value in settings.json file in VSCode. But it didn't work. I tried to add VMArgs in launch.json also. The error still persists. I tried to add -javaagent in argline tag through pom.xml as a plugin. But nothing seems to be working.

PS: I have tried using -javaagent in settings.json. It's also not working. The code(A simple static method with bare minimum code) works fine with STS. How to make it work with VSCode?

How to make VS Code not open a terminal when debugging?

$
0
0

I've installed VS Code on Ubuntu 17.04.

When I debug my C++ application, the output is displayed in a dedicated terminal and not within VS Code itself (like Eclipse does).

How do I make VS Code display output within the editor itself, i.e., not open another terminal?

My launch configuration is as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gdb",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.out",
            "args": ["foo", "bar", "baz"],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++"
        }
    ]
}

I'd hoped that setting externalConsole to false would solve the problem. However, it didn't change anything.

VS Code - Add a new file under the selected working directory

$
0
0

I'm trying to get a shortcut to add a new file under my current working folder. So I navigate to the explorer using cmd+shift+e and when I get to the folder I want to create a new class I do cmd+n which creates me a new file but is not saved anywhere (I'm trying to get a similar behaviour to what ReSharper does for instance).

Is there any other shortcut to get the file created under the folder you have the focus in the explorer? Essentially I could like to get the text box to fill in the name then the file gets automatically saved so that I don't get the prompt later on.

I'm using for reference the following page: https://code.visualstudio.com/docs/customization/keybindings

Can I ssh from WSL in visual studio code?

$
0
0

I am using WSL on windows 10 to program, and recently discovered that VS code can be used to edit programs through SSH.

However, I normally SSH into my university's computers through WSL so i can access the files on those systems and use their GPUs.

Is there any way to SSH into WSL using vscode, and then ssh into my universities systems, and have access to their resources and filesystems from with within vscode?


VScode How to encode and save multiple files at once

$
0
0

I'm very new to programming.

I have over 100html files written in Shift-JIS that needs to be re-encoded in UTF-8. I know how to do this on Visual Studio Code for a single file; by clicking on the code language at the bottom right of the page.

However, repeating this process for over 100 files is just too much time consuming and troublesome. Is there a way to do the "save with encoding" process for multiple files at once using vscode?

Thanks

Launch.json: how to reference an environment variable

$
0
0

In order to define my environment variables in a single place a configured a task in which a run a shell script. The task is run as preLaunchTask in my launch.json.

In my launch.json I now try to reference the environment variables I configured in the script (like export AWS_REGION="eu-west-1").

The launch.json looks as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            //..
            "env": {
                //"AWS_REGION": "us-east-1",        //works
                "AWS_REGION": "${env:AWS_REGION}",  //doesn't work, why?
            },
            "args": [],
            "preLaunchTask": "setupEnv",
        }
    ] }

Vscode gives "ModuleNotFoundError", when running python script with right corner arrow

$
0
0

When debugging, it doesn't give error, but works ok. I tested with one line: import fiona

How do I change the size of a space in VSCode? [closed]

$
0
0

VSCode Version: 1.41.1
OS Version: Ubuntu 18.04.3 LTS

In my VS Code, the space is only half the size of one character. How do I change the size of a space to one character?

enter image description here

What i should i do to solve problem on using vs code [java]

$
0
0
package Java;
public class HelloWorld {
    public static void main (String[] args)  {
        System.out.println("HelloWorld!");
    }
}

This is a code that i tried on VS code with java.

At first time, I compiled it compiled successfully printing HelloWorld!. But if i compile again it prints red font message looks like having error.

First time -> HelloWorld! PS C:\Users\김민제\VS>

Second time -> HelloWorld! PS C:\Users\김민제\VS> \scripts\launcher.bat''C:\Program Files\Java\jdk-13.0.1\bin\java''--enable-preview''-Dfile.encoding=UTF-8''-cp''C:\Users\김민제\AppData\Roaming\Code\User\workspaceStorage\a9e20c842732c44b1b61cf6f8002d557\redhat.java\jdt_ws\VS_bfc6420b\bin''Java.HelloWorld'

Third time ->

HelloWorld! PS C:\Users\김민제\VS> \scripts\launcher.bat''C:\Program Files\Java\jdk-13.0.1\bin\java''--enable-preview''-Dfile.encoding=UTF-8''-cp''C:\Users\김민제\AppData\Roaming\Code\User\workspaceStorage\a9e20c842732c44b1b61cf6f8002d557\redhat.java\jdt_ws\VS_bfc6420b\bin''Java.HelloWorld'>> cd 'c:\Users\김민제\VS'; & 'C:\Users\김민제.vscode\extensions\vscjava.vscode-java-debug-0.24.0\scripts\launcher.bat''C:\Program Files\Java\jdk-13.0.1\bin\java''--enable-preview''-Dfile.encoding=UTF-8''-cp''C:\Users\김민제\AppData\Roaming\Code\User\workspaceStorage\a9e20c842732c44b1b61cf6f8002d557\redhat.java\jdt_ws\VS_bfc6420b\bin''Java.HelloWorld'>> bug-0.24.0

And on and on....

What should i do??? On my desktop computer it works well with similar setting. But my notebook doesn't work...

Vertical rulers in Visual Studio Code?

$
0
0

How can vertical rulers (note the plural) be configured in Visual Studio Code?

In Sublime Text 2 I can do

"rulers": [72, 80, 100, 120]

How does this work in Visual Studio?

"editor.ruler": 80

produces only one vertical ruler.

How can I prevent zombie processes caused by pool.map while using "spawn" context?

$
0
0

I am running python 3.6 through VSCode on WSL Ubuntu. My code repeatedly calls the function f() below:

def do_nothing(folder):
    print("I'm process", os.getpid())
    logfile = os.path.join(folder, 'stdout.out')

def f():
    folders = [str(i) for i in range(8)]
    with multiprocessing.get_context("spawn").Pool() as pool:
        pool.map(do_nothing, folders)

This creates many zombie processes with the following signature which outlive the calling program:

 PID TTY          TIME CMD
2710 ?        00:00:00 at-spi2-registr

The PIDs of these processes do not match the PIDs of any of the Pool's processes. The numbers are very close though.

Is there a way I can avoid this? I suspect switching to fork would fix the issue, but the reason I am using get_context("spawn") is because with fork VSCode throws up an error for each forked process saying it can't debug, and that is an unworkable solution.


Best practice on using Github / Visual Studio Code for automatic deployment on two differerent environnements (dev/prod)

$
0
0

Here is current the context:

  • One developper (myself) working from two different PC's with Visual Studio Code
  • One master branch on Github with automatic deployment via a Webhook on the production server

Currently, I launch this each time VS code starts (on both PC's), and it works pretty fine:

git fetch --all
git reset --hard origin/master
git checkout --force origin/master

On the server side, the Webhook calls a script running:

<?php    
if ($payload->ref === 'refs/heads/master') {
   $commands = array(
      'cd /home/www-data/production',
      'git fetch --all',
      'git reset --hard origin/master',
      'git checkout --force origin/master'
   );
}
foreach($commands AS $command) {
   $tmp = shell_exec($command);
}

I am quite happy with this but now, I would to be able to work on a development server.

My idea was to create a dev branch, and automatically deploy it the same way. Considering that these are microdevelopments (bug correction) and I don't want to preserve the Dev branch, I've added:

Adding this locally on VS Code on startup:

git reset --hard origin/dev
git branch -D dev
git checkout -b dev origin/dev

Adding this on the server before the foreach loop:

elseif ($payload->ref === 'refs/heads/dev') {
   $commands = array(
      'cd /home/www-data/development',
      'git fetch --all',
      'git reset --hard origin/dev',
      'git branch -D dev',
      'git checkout -b dev origin/dev'
   );
}

So the idea was to push the dev branch, check everything is ok, then merge dev on master.

I have made some tests, but Production environment is overwritten each time I publish on the dev branch.

Before digging on that, I'd like to know it this is the better way to proceed, or not.

How to trigger parameter hints in Visual Studio Code?

$
0
0

I want to show parameter hints when I position cursor within the parentheses of the calling method.

I know similar answers already exist for Visual Studio on Reddit, but I couldn't find a quick answer for this question on Stack Overflow. So I've decided to add it.

Installing Visual Studio Code locally without user privileges

$
0
0

Using Debian GNU/Linux 10 (buster).

I would like to install Visual Studio Code in a way that does not require superuser privileges. I am working on a computer within a network for which I do not have such privileges, neither do I have great hopes to persuade system administrators to help out with this, at least efficiently.

Therefore, I was thinking to install the program in my own home directory, as done with other programs other times. I have found these two ways which both require me superuser privileges

  • via Anaconda Navigator 1.9.7
  • via the command line dpkg -i code_1.42.0-1580986622_amd64.deb --root=<my location>

Are there ways to work around this bareer and install the program locally? The intended use of VS Code is about editing source files in a variety of languages, a.o. Python and C++. So I should be able to install the attending extensions likewise, else this program is, alas, not for me.

Thanks for tips and suggestions.

VSCode is not saving changes in Jupyter Notebook (unless I run the cells with changes)

$
0
0

I've been losing changes I've made to some of my cells because although I saved the notebook file, I didn't actually run the cell (this is for both code and markdown cells). And when I close the file down there is no warning of the sort "do you want to save changes?".

I know the workaround is to just run cells before saving. But it's just not a robust working setup.

Anyone got solutions? I would even switch editor to something with a similar feel if there's an alternative.

Unusual behavior, cannot find name 'Array'

$
0
0

I am trying to use the array functionality in angular 7 but I am facing the error saying, cannot find name 'Array'. Similarly, I am not able to use the simple array methods like push and pop.

Here is the sample

Angular7 is not letting me initialize the variable like:

list: Array<number> = [1, 2, 3];

What is the root cause and how to resolve it?

Updated: tsconfig.js

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

Moreover, code is compiling without error.

code compilation successfull

Mysterious Resolution: I manage to resolve the compilation error by updating the visual studio code. The issue was particularly with the visual studio code update.

Viewing all 98612 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>