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

VsCode - Is there a way to maintain last selected text after edit/delete?

$
0
0

Coming from Eclipse I used to use the Find Next functionality (cmd+k in my Eclipse IDE) to do a very quick search and replace because after you've selected text and moved to the next instance it is retained in memory even if the cursor's selection is blank, whereas vsCode will automatically expand the selection to the adjacent word if the selection is blank. I know that can be accomplished with find and replace but was looking for a similar short cut to provide the following.

E.g - Copy some text into the clipboard. - Navigate and highlight target text you wish to replace. - Use Find Next to navigate to next instance. - Paste the clipboard over the selection, leaving the cursor at the end of the word and without selection. - Use Find Next (cmd+k in my IDE) to navigate to next instance of the target text. - Repeat as necessary, sometimes just using Find Next without replacing.


How to get intellisense in Visual Studio Code for Unity functions names?

I am facing problem while iterating over a string vector

$
0
0

I was trying to make a program to convert numbers into words using the range-based loop for string vector.

    // conversion of numbers into word 
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    vector<string> words = {"one", "two", "three","four","five","six", 
    "seven", "eight", "nine"};

    for(int x:words){
      cin>>num; 
      if(num==words[x]) cout<<words[x]; 
    } 
    return 0;
}


// this program is showing error:
{
"message": "no suitable conversion function from\"std::__cxx11::string\" to \"int\" exists",

}

// If inside the 'for statement' I change int x to auto x this is working fine. I don't understand what difference does this makeS.

'eslint' is not recognized as an internal or external command

Possible to add palette command running another command with arguments?

$
0
0

Is it straightforwardly possible to define a command to be added into VS Code's command palette, which runs an existing command with specified arguments?

Concrete example: I have installed the Alignment extension, and want to use it to align Ruby symbol-key hashes like so:

{
  key:        'foo',
  anotherKey: 'bar',
  myKey:      'ponk'
}

I can do this by invoking Align by regex, then in the palette dialog that opens giving the regex (?<=:) \w.

Picking "Align by regex" from the paletteFollowing up by entering the regex

Naturally, that's a pain to type each time. Can I define a palette command to do that in one step?

VSCode nested snippets (or include a snippet inside another snippet)

$
0
0

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.

VSCode import "C" fails

$
0
0

Please see the following screenshot:

vscode with golang import "C" error

It says:

could not import C (no package data for import path C)

I am using Go 1.13 with the latest versions of each extension for Go and C/C++. There is no compiler error, and this is specifically seemingly isolated as a "vscode problem".

Is there a way to fix this vscode problem?

In VS Code, is it possible to disable code unfolding when the user clicks the blank area preceding the "..."?

$
0
0

Excluding keyboard shortcuts, folded regions in VSCode can be unfolded by clicking on one of three places:

  1. [+] button in the gutter area
  2. The "..." immediately preceding the last character of the first line of code in that region
  3. Anywhere in the blank area to the right of the "..."

Is it possible to write an extension that disables the last one? I tend to randomly click around in my code while I'm thinking which leads to unintentionally unfolding regions of code and loosing my spot.


Is it possible to add auto-completion into external code editors for Unity

$
0
0

I just started using Unity with Visual Studio Code and got it up and running to use it instead of the default code editor but VSC doesnt display auto-completion and I am wondering if it is even possible to add this feature into Visual Studio Code and if yes, how to do so.

How to install Visual Studio code on Fedora 12?

$
0
0

Does Visual Studio Code work on Fedora 12 ? I see that it works on Fedora, but will it work on an old version of Fedora 12. I had trouble understanding the install process using snapd any help would be appreciated.

Why does the VS Code integrated terminal not work if I'm invoking a Typescript build task?

$
0
0

I'm editing Typescript files in VS Code, and when I invoke the build task via Shift-Cmd-B, I get

`env: node: no such file or directory'

but if I start the terminal and manually type the same command it's using, which is

tsc -p /Users/Mike/Sync/projects/teaching/blendoku/tsconfig.json

it works fine. What is different about the shell that is launched with the build and watch tasks?

Bash shell doesn't work properly (VSCode)

$
0
0

I've started setting up VScode for python and I have a problem with the git bash shell that I've installed and already added to user settings. The terminal switched to bash but it doesn't look right and it won't work. It looks like this:

enter image description here

And as long as I know it should look like this: enter image description here

So what's the problem?

How to customise the textMateRules for multiple themes in VS Code?

$
0
0

In VS Code, I'd like to customise some textMateRules the same for multiple themes. For example, both for Atom One Dark and Default Dark+ but without affecting any of the other themes, I'd like to make the keywords italic. I can achieve this by duplicating the same settings twice separately for each theme as below

"editor.tokenColorCustomizations": {
    "[Atom One Dark]": {
      "textMateRules": [
        {
          "scope": [ "keyword" ],
          "settings": { "fontStyle": "italic" }
        }
      ]
    },
    "[Default Dark+]": {
      "textMateRules": [
        {
          "scope": [ "keyword" ],
          "settings": { "fontStyle": "italic" }
        }
      ]
    }
  }

How can I only need to set up once for both, without duplicating the rules, especially if there are a lot same rules for the multiple themes? Something like the below (but which doesn't work though)

"editor.tokenColorCustomizations": {
    "[Atom One Dark] [Default Dark+]": {
      "textMateRules": [
        {
          "scope": [ "keyword" ],
          "settings": { "fontStyle": "italic" }
        }
      ]
    }
  }

Can I add a mouse click callback to decorated text?

$
0
0

I have a decoration applied to the portion of text (matched with regex) it has the option to specify a hoverMessage I'm wondering if there is a way to specify a mouse click to this element. I would like to execute some function based on which decorated text user clicked.

VS Code + Arduino IDE: How to select which sketch will compile? Missing something obvious here

$
0
0

Long-time Arduino IDE user, one-day VS Code + Arduino extension user:

When I first load a sketch and do "Arduino:Initialize", the name of the sketch is stored in the arduino.json settings file, e.g. "sketch": "esp32_test/esp32_test.ino". It then compiles ok when I press the "Verify" button.

But if I close that sketch and open a different one, and then do "Arduino:Initialize", the first file is NOT replaced in the arduino.json file. The first one remains there. I get a message that says, "Arduinio.json is already generated." So when I try to compile the new file, the old one is compiled instead.

The only way I've been able to compile a different file is to manually edit the arduino.json settings file to remove the "sketch": "esp32_test/esp32_test.ino" entry. Then AND ONLY THEN will the .json file update to allow me to compile the new file.

Shouldn't this happen automatically when I select/edit a file and hit the Verify button? Maybe there's an issue with my installation...?

(forgot to mention: VS Code + Arduino on OSX 10.14.6)


Error Message Dart 2.5 The for, if, and spread elements weren't supported until version 2.2.2

$
0
0

Use of the spread (...) element produces the following error:

"The for, if, and spread elements weren't supported until version 2.2.2, but this code is required to be able to run on earlier versions. Try updating the SDK constraints."

Changing pubspec.yaml to:

 environment:
    sdk: ">=2.x <3.0.0"

for values of x from 2.2 up to 5.0 doesn't remove the error. Autofix just sets it to ">=2.2.2 <3.0.0".

The code runs fine, it's just an annoyance as there is one instance of the error for each file it's used in - which leads to the Problem window being full of pointless messages. Is there the possibility that something is requiring a lower version of the sdk, and if so what/where might it be?


Flutter 1.9.1+hotfix.6 • channel stable • https://github.com/flutter/flutter.git

Framework • revision 68587a0916 (6 weeks ago) • 2019-09-13 19:46:58 -0700

Engine • revision b863200c37

Tools • Dart 2.5.0

Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 10.0.18362.295], locale en-GB)

Android toolchain - develop for Android devices (Android SDK version 29.0.1)

Android Studio (version 3.4)

Where to define a shared problemMatcher to check the terminal?

$
0
0

In vscode I experience sometimes I can click on build errors in the integrated terminal and sometimes it is not possible to do so. This has annoyed me for quite some time because I was not able to find a pattern, until today when I was editing tasks.json.

It looks to be related to defining a problemMatcher in .vscode/tasks.json. Removing the problemMatcher section from the file and build errors in terminal were no longer clickable but putting it back did not re-enable them.

My vscode-project is located in a subfolder of the build tree and its build root for the entire project is two levels up ${workspaceFolder}/../.. which I believe maybe could confuse some build tools.

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "problemMatcher": {
        "fileLocation": "relative",
        "severity": "error",
        "pattern":{
            "regexp": "^system/mytool/(.*):(\\d+):(\\d+):\\s+(warning|error):(.*)$",
            "file": 1,
            "location": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        },
    },
    "tasks": [
        {
            "type": "shell",
            "label": "android deploy",
            "command": "cd ${workspaceFolder}/../..; source build/envsetup.sh ; lunch hikey960-userdebug ; m mytool",
            "args": [
            ],
            "options": {
            },
            "group": "build"
        },

    ]
}

I have seen examples putting "problemMatcher" = "$gcc" inside the task,should I define my problem matcher globally somewhere else and refer to it my name instead?

How to use it to parse the output when I build by typing make-commands in the integrated terminal?

VSCode Python version defaults to 2.7 in the integrated terminal

$
0
0

I have VScode installed on iMac with Catalina. On the vscode the interpreter defaults to python 2.7. It remains same even after I change python interpreter and python path. I have referred to following questions with out any success.

Question 01

Question 02

Any help is much appreciated.

Is there a way to edit codes in kubernetes pods using VS Code?

$
0
0

Typically, if I have a remote server, I could access it using ssh, and VS Code gives a beautiful extension for editing and debugging codes for the remote server. But when I create pods in Kuberneters, I can't really ssh into the container and so I cannot edit the code inside the pod or machine. And the kuberneters plugin in VSCode does not really help because the plugin is used to deploy the code. So, I was wondering whether there is a way edit codes inside a pod using VSCode.

P.S. Alternatively if there is a way to ssh into a pod in a kuberneters, that will do too.

Open a script in a new tab in VS code

$
0
0

Typically when I want to open a code and edit in VS code, I run the command code code_name.py in the terminal in the VS code. In the past, the code would just be opened in a new tab, which is exactly what I want. However, recently, when I used code code_name.py, the script would be opened in a new window instead of a new tab in the same window. I've been looking for a solution for a long time but it seemed that there was not a post relevant to my problem. Could anyone please provide some suggestions on this? Thank you very much!

Viewing all 98319 articles
Browse latest View live


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