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

Can I set the VS Code default EOL based on file type?

$
0
0

Working with .sh files on Windows causes issues when running them in Linux Docker containers if they have EOL of CRLF. Can I make VS Code always work with LF for specific file type such as .sh while still using CRLF for all others?

I only find "files.eol": "\r\n" in settings, but this is global.

I understand you can change this in the bottom toolbar on a per-file basis, but I would like this to be the default for all .sh files.


How to make Visual Studio Code tabs behave like expected ? (web navigator..ect)

$
0
0

i find the current way of handling new tabs/windows really frustrating in visual studio code.

tabs should behave like chrome or any other navigator like the gif below

is it possible to do this in VS Code ?

enter image description here

Visual Studio Code compiles with npm, node.js but does not show GUI interaction on localhost:42000

$
0
0

I just successfully installed npm 6.12, Node.js version 12.13 on my Ubuntu 19.04. I also successfully compiled a project using Visual Studio Code. It is my first time using VS and I have been trying to build this project with partial success and I don't understand why, despite the project compile successfully, it does not build.

Below the organization of the project tree:

organization-tree

This is the outcome of the terminal after a launch npm start where I successfully compile but not build:

compile

Finally I can confirm that this is partially working because the localhost:4200 is actually working as is possible to see from the print screen below:

localhost

What I tried so far

I tried many different options from launching npm in any possible way from the terminal line embedded in VS, but also using Linux command line.

I went through the entire project and installed all missing libraries such as: scipy, matplotlib and pandas and numpy but still nothing on the localhost side.

In addition I have tried to start and stop several times npm but no luck.

The Problem

I should be able to interact with a graphical user interface but what I see is only the localhost:4200 page without any interaction and only red-ish colored.

What am I doing wrong or missing? Thanks for pointing in the right direction.

Google Styleguide Java Format for VSCode

$
0
0

Is there a good extension or proven methodology to automatically format Java code in VSCode to adhere to Google's Java Styleguide? Nothing from the list of links below seems to work for my set-up. I get a soft-fail and nothing changes about formatting.

Version: 1.39.2 (user setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.16299

google-java-format
GitHub - Formatting VSCode : 419
GitHub - Formatting VSCode : 450
GitHub - Formatting VSCode : 663
Formatter Settings
Eclipse Java Google Style XML
VS Java Editing - Main Page
VSCode Extension - Checkstyle

Pylint "unresolved import" error in visual studio code

$
0
0

I am using the following setup

  • MacOS Mojave
  • Python 3.7.1
  • Visual Studio Code 1.30
  • Pylint 2.2.2
  • Django 2.1.4

I want to use linting to make my life a bit easier in visual studio code however, every import i have states "unresolved import". Even on default django imports (i.e. from django.db import models).

I presume it is because it is not seeing the virtual environment python files.

Everything works just fine but but it's starting to get annoying.

The interpreter choices i have are all system versions of python. It does not seem to see my virtual environment python at all (it is not in the same directory as my workspace, so that part makes sense).

If i setup the python.PythonPath in the settings.json file, it just ignores it and does not list my virtual environment path as an option. I also tried setting it up in my global python settings but it also does not show up.

Has anyone run into this issue and know a quick fix to get it working?

Thanks, jAC

Cannot download Pillow in Django VSCode project (Windows)

$
0
0

I'm going through Django 2.2 course with Windows / VSCode / Anaconda setup. I've tried to use both Python 3.6 and 3.7 interpreters and tried to download Pillow with commands such as:

  • pip install Pillow
  • python -m pip install pillow
  • pip install Pillow==5.0.0

I've tried to execute this both in is Anaconda Shell Prompt and cmd. Simply put, I get error of missing Pillow package whatever I do. When I try to execute "conda install" it says the the requirement is already satisfied, but it still doesn't recognize the package.

See attached pictures about errors.

Error1

Error2

Setting up devcontainer.json as non-root user in VSCode

$
0
0

I'm trying to setup VSCode for remote development with docker container, but keep having permission issues when trying to install vscode-server inside the container.

Setting up container for folder or workspace: /home/username/4NN3-Neural-Networks-and-Deep-Learning
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db /bin/sh -c (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Run: docker cp 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db:/etc/passwd -
Forking shutdown monitor: /home/username/.vscode/extensions/ms-vscode-remote.remote-containers-0.81.1/dist/shutdownMonitorProcess /run/user/1001/snap.code/vscode-remote-containers-a2996f7f87a405d00b1db59d2b1d8d9b31ef07dc.sock singleContainer no-trace
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db test -d /home/username/.vscode-server
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db test -d /home/username/.vscode-remote
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db /bin/sh -c set -o noclobber ; mkdir -p '/home/username/.vscode-server/data/Machine'&& { > '/home/username/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
mkdir: cannot create directory ‘/home/username/.vscode-server’: Permission denied
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db /bin/sh -c set -o noclobber ; mkdir -p '/home/username/.vscode-server/data/Machine'&& { > '/home/username/.vscode-server/data/Machine/.copyGitConfigMarker' ; } 2> /dev/null
mkdir: cannot create directory ‘/home/username/.vscode-server’: Permission denied
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db test -d /home/username/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390
Installing VS Code Server for commit 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Run: docker exec 9181871e4be347ece95c47cce6ec717d8cce9d8e2febe3fd3e7ea98984a434db mkdir -p /home/username/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390_1572636263815
mkdir: cannot create directory ‘/home/username/.vscode-server’: Permission denied

My Dockerfile is bellow:

FROM tiangolo/python-machine-learning:python3.6

LABEL version="1.0"
LABEL description="Dev Environment for McMaster University, SFWRTECH 4NN3 Course"

# Update Conda
RUN conda update -n base -c defaults conda

# Install ML Libraries  
RUN conda install -y tensorflow
RUN conda install -y keras
RUN conda install -y numpy
RUN conda install -y scipy
RUN conda install -y scikit-learn
RUN conda install -y pandas
RUN conda install -y matplotlib
RUN conda install -y pylint

# Creating New User and Set Password
RUN useradd --create-home --shell /bin/bash username
RUN echo 'username:passw0rd' | chpasswd

# Set User & WORKDIR
USER username
ENV HOME /home/username
WORKDIR /home/username

The container created from the image in regular terminal runs just fine. This seems to be a recurring issue, I've tried a few solutions proposed in issue tracker in github here and here both propose to set the $HOME to /home/username.

I've set the $HOME in both the Dockerfile and devcontainer.json, but the issue persists, anybody a workaround for this?

The devcontainer.json is bellow:

{
    "name": "4NN3 Dev Container",
    // Sets the run context to one level up instead of the .devcontainer folder.
    "context": "..",
    // "dockerFile": "../Dockerfile",
    "image": "4nn3-mcmaster",

    "runArgs": [
        // See https://aka.ms/vscode-remote/containers/non-root-user
        // "-u", "username""--env", "HOME=/home/username/"
    ],

    "settings": {
        "terminal.integrated.shell.linux": null
    },

    "workspaceMount": "src=${localWorkspaceFolder}/,dst=/home/username/,type=bind,consistency=delegated",
    "workspaceFolder": "/home/username/",

    "extensions": ["ms-python.python", "eamodio.gitlens"]
}

js 'types' can only be used in a .ts file - Visual Studio Code using @ts-check

$
0
0

I am starting to use TypeScript in a Node project I am working on in Visual Studio Code. I wanted to follow the "opt-in" strategy, similar to Flow. Therefore I put // @ts-check at the top of my .js file in hope to enable TS for that file. Ultimately I want the same experience of "linting" as Flow, therefore I installed the plugin TSLint so I could see Intellisense warnings/errors.

But with my file looking like:

// @ts-check

module.exports = {
  someMethod: (param: string): string => {
    return param;
  },
};

and my tsconfig.json file looking like...

{
  "compilerOptions": {
      "target": "es2016",
      "module": "commonjs",
      "allowJs": true
  }
}

I get this error: [js] 'types' can only be used in a .ts file. as shown below in the image.

error from vscode for ts

I saw this question which recommended disabling javascript validation in vscode but then that doesn't show me any TypeScript Intellisense info.

I tried setting tslint.jsEnable to true in my vscode settings as mentioned in the TSLint extension docs but no luck there.

What is the correct setup in order to use .js files with TypeScript and get Intellisense so I know what the errors in my code are before I run any TS commands?


Visual Studio Code wont run code and gives no error message

$
0
0

So when running any code, no matter the language visual studio ignores the code and just doesn't run. all i see is it skips to the next line in the terminal and gives no output. Not even something like hello world runs. It gives no error message whatsoever, just doesn't run.

How to remove the file extension using a snippet variable. List of snippet variables

$
0
0

I use vscode.

I want to use costum snippets, but {TM_FILENAME} has an extension name.

How can I delete the extension from {TM_FILENAME}?

like this:`

In file MyModule.js:

Transform: ${TM_FILENAME/(\w+)\.js/\1/g}

Output:

MyModule

vs code can't replace using regex group references under PCRE2 mode

$
0
0

I'm trying to replace my std stl usage to EASTL and since i have a lot of cpp/h files, i'm relying in 'Search in Files' option of vs-code, with the following pattern:

((?<=#include \<)([^\/(.h)]+?)(?=\>))

This matches completely fine in regexr.com, in both match and replace and in vs code as well but needs the option of PCRE2 engine being enabled due backreferences use.

Trying to reference the matching group #1 using $1 under Search sidebar view simply doesn't work, and just adds "$1".

enter image description here

But if i search & replace with the same input for each file manually, it works as intended.

enter image description here

Thanks.

Integrated terminal in visual studio code is opening externally and not internally

$
0
0

I have reinstalled Visual Studio Code and for some reason, when I do the Ctrl+Shift+` shortcut, instead of opening a terminal window inside VS Code, it's opening an external command window, which is very annoying.

Anyone knows what setting it is to get it back internally?

I tried File->Preferences->Settings->Terminal and then set the first option "Customizes what kind of terminal to launch." to integrated.

Is there any other setting I need to set?

Visual studio code is not showing the ouput of python

$
0
0

I am really new to Python and just started the course "Python 3 basics by Sendtex (Link: https://www.youtube.com/channel/UCfzlCWGWYyIQ0aLC5w48gBQ)".

  • I am trying to use Python with Visual Studio Code.
  • The downloaded version of Python is 3.6.4.
  • I have installed the Python extension in Visual Studio Code and have followed the procedure.

However, I am not able to get any output. Below is the attached screenshot. enter image description here If I select Python it enters in debugging mode. So, there isn't any output. Thanks in advance.

vs code cannot find module '@angular/core' or any other modules

$
0
0

my project was generated with [Angular CLI] version 1.2.6.

I can compile the project and it works fine, but I always get error in vs code telling me cannot find module '@angular/core' cannot find module '@angular/router' cannot find module .....

screenshotscreenshot

I have attached content of my tsconfig.json file this has been really frustrating for me, spending 2 hours to figure out what is wrong, I have also uninstalled and reinstalled the vs code it doesn't work.

here is my enviroment specification :

@angular/cli: 1.2.6
node: 6.9.1
os: win32 x64
@angular/animations: 4.3.4
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/router: 4.3.4
@angular/cli: 1.2.6
@angular/compiler-cli: 4.3.4
@angular/language-service: 4.3.4

os:Microsoft vs 10 enterprise

project root folder

.angular-cli.json
.editorconfig
.gitignore
.vscode
e2e
karma.conf.js
node_modules
package.json
protractor.conf.js
README.md
src
tsconfig.json
tslint.json

node_module folder

-@angular
--animations
--cli
--common
--compiler
--compiler-cli
--core
---@angular
---bundles
---core.d.ts
---core.metadata.json
---package.json
---public_api.d.ts
---README.md
---src
---testing
---testing.d.ts
---testing.metadata.json
--forms
--http
--language-service
--platform-browser
--platform-browser-dynamic
--router
--tsc-wrapped
@ng-bootstrap
@ngtools
-@types
--jasmine
--jasminewd2
--node
--q
--selenium-webdriver

tsconfig.json :

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

How to execute a VisualStudioCode extension in command line?

$
0
0

I want to export a markdown document to PDF using the "Markdown PDF" extension in VisualStudioCode per command line. Is it possible? How to do it?


Add an extension to an existing extension.js in visual studio code

$
0
0

I want to add an extension(for e.g. Docker extension) to my existing extension and repackage it as one single extension.

Updating OmniSharp extension

$
0
0

My C# for Visual Studio Code extension is at 1.21.5. How do I update it to the latest 1.34.4?

There is a Disable button and an Uninstall button, but I can't find an option to perform an update.

The Check for Extension Updates menu button when clicked simply says "All extensions are up to date."

The extension is enabled globally, if that is of relevance.

Selectively surpress VSCode warnings/errors that are not relevant in deloyment

$
0
0

I'm working on a project in which one of the .py files is spun up in a container (Worker.py). This file imports from other .py files in the project which are appended to the system path so that it all works. It looks like this:

import os

sys.path.append('/app/src/')

from utils.general_utils import generic_function
from handler.task_handler import TaskHandler

VSCode throws an "unable to import utils.general_utils" error, since it, of course, has no knowledge beforehand of what gets put where in a container. Hence, I believe the best solution would be to suppress these errors. However, I'd prefer not to just disable import errors since for other parts of the project it is still useful.

How can this be done, or is there a better alternative solution?

Stop -Wall -Wextra popup so that a user can compile a program without having to press 'Enter' or 'Esc'

$
0
0

I am trying to learn C++ using VS code in Ubuntu 19.10. I use two C/C++ extensions for this. Now the problem is I have to click the screen twice in order to view the terminal output. Its really getting my nerve. I don't know what that notification is trying to tell, but its really slowing down my performance. How to stop this Flags when its clearly not necessary for me now?

Screenshot of problem

Two extensions which I used for C++ are:

  • C/C++ Compile Run by danielpinto8zz6
  • C/C++ by Microsoft

How to get folderpath name of currently opened file in visual studio code

$
0
0

I have opened multiple angular projects in visual studio code and i am trying to get cuttenlty opened file's project folder path inside my extension. But I am not getting the correct path . Anyone know please help to find the solution.

Below script only will work if I open single angular project in VS Code but how do for if I open multiple project folders.

extension.js:

exports.activate = context => {
const mymodules = vscode.commands.registerCommand('extension.search', () => {

var rooturi = vscode.workspace.workspaceFolders[0].uri;
var folderpathnameofcurrentlyopenedfile=rooturi.fsPath;  // currently opened file's project folder path[Opened single project]
Viewing all 97327 articles
Browse latest View live


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