Home >Development Tools >VSCode >How to use relative paths in vscode

How to use relative paths in vscode

angryTom
angryTomOriginal
2020-02-10 17:51:519336browse

How to use relative paths in vscode

How to use relative paths in vscode

The relative paths in vscode are different from those in general editors. For specific differences, please refer to the following table

Symbol vscode General
“./2 .txt" Relative to the working path (where the .vscode folder is located) Relative to the current running file
"2.txt" Relative to the working path Relative to the current running file
"/2.txt" Relative to the disk root directory Relative to the disk root directory

Usage example:

How to use relative paths in vscode

Requirements: The working path is as above, The execution file is readfile .py, and you need to obtain the 1.txt file

Solution 1: Use the corresponding relative path

, that is, according to the working path To find the relative path is "./greatProject/godsearch/1.txt"

Solution 2: Change launch.json settings

How to use relative paths in vscode

Add the statement

"cwd": "${fileDirname}"

to the configurations to become a regular relative path mode

How to use relative paths in vscode

To obtain the relative path, just "./1.txt" or "1.txt"

Recommended related articles and tutorials: vscode tutorial

The above is the detailed content of How to use relative paths in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn