标签: visual-studio-code

Visual Studio Code:如果在某行文本中找到字符串,如何删除该行文本?

我想使用 Visual Studio 代码查找一串文本,并在检测到该文本字符串时删除整行。

visual-studio-code

1
推荐指数
1
解决办法
2548
查看次数

VS 代码片段 - 只保留第一个点之前的文件名

我只想保留第一个点之前的单词:

user.entity.ts
Run Code Online (Sandbox Code Playgroud)

当前代码:

${TM_FILENAME_BASE/([^.]+)/${1:/upcase}/}
Run Code Online (Sandbox Code Playgroud)

不幸的是,这只是转换了第一部分,而不是把它分开:

USER.entity
Run Code Online (Sandbox Code Playgroud)

visual-studio-code vscode-snippets

1
推荐指数
1
解决办法
603
查看次数

在 VS Code 中使用 scanf 和 Code Runner 扩展

我尝试了一个非常简单的C语言代码scanf,它陷入了无限循环(或者看起来像)。代码如下:

#include <stdio.h>

int main(){
    int input = 0;
    scanf("%d", &input);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我使用了代码运行器扩展。这是以防万一的屏幕截图。 在此输入图像描述

有谁知道如何修理它?

c visual-studio-code vscode-code-runner

1
推荐指数
1
解决办法
3811
查看次数

如何在android studio或者vscode中搜索整个Flutter源码

在Android Studio中,我们可以使用“ctrl+shift+f”(在Windows中)在项目中搜索,

但这仅显示我们自己项目内的搜索结果。

我们怎样才能在整个Flutter源码中搜索到任意一个类或者方法呢?

(比如我想搜索BackdropFilterFlutter源码中的类,该怎么办?)

我们可以在 IDE 中使用“转到定义”,但我只想搜索。

dart android-studio visual-studio-code flutter

1
推荐指数
1
解决办法
2943
查看次数

为 HTML 文件配置 Prettier

我查看了 Prettier 的文档并进行了大量搜索,但无法弄清楚如何按照我想要的方式配置 Angular html 文件。如果元素不超过一行的最大字符数,我希望元素位于一行上,但如果确实超过最大值,那么我只需要每行一个属性,如下所示。

所需的格式:

<app-example-component [attribute1]="attribute1"></app-example-component>

<app-example-component
  [attribute1]="attribute1"
  [attribute2]="attribute2"
  [attribute3]="attribute3"
  [attribute4]="attribute4"
></app-example-component>
Run Code Online (Sandbox Code Playgroud)

这是我目前得到的,我发现很难阅读:

<app-example-component [attribute1]="attribute1" [attribute2]="attribute2"
  [attribute3]="attribute3" [attribute4]="attribute4"
  [attribute3]="attribute3" [attribute4]="attribute4"
  [attribute3]="attribute3"></app-example-component>
Run Code Online (Sandbox Code Playgroud)

我正在使用 VS Code,并且最近将我的 Angular 项目转换为使用 ESLint 而不是 TSLint,但在此之前我没有使用 Prettier,所以我不知道该转换是否会导致问题。

这是我的.eslintrc.json文件。也许这对我来说破坏了 Prettier?

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parserOptions": {
        "project": [
          "tsconfig.json",
          "e2e/tsconfig.json"
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/ng-cli-compat",
        "plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@typescript-eslint/consistent-type-definitions": "error",
        "@typescript-eslint/dot-notation": "off",
        "@typescript-eslint/explicit-member-accessibility": [
          "off",
          {
            "accessibility": "explicit"
          } …
Run Code Online (Sandbox Code Playgroud)

eslint visual-studio-code angular prettier

1
推荐指数
1
解决办法
5386
查看次数

Rust 和 VSCode 中的新行中继续 Docstring

考虑如下结构:

struct Foo;
Run Code Online (Sandbox Code Playgroud)

我想为此写一些文档,所以我这样做:

/// whatever
struct Foo;
Run Code Online (Sandbox Code Playgroud)

但是,当我按 Enter 时,它会创建一个空行:

/// whatever

struct Foo;
Run Code Online (Sandbox Code Playgroud)

不是在文档字符串中添加新行,而是///在其前面添加:

/// whatever
///
struct Foo;
Run Code Online (Sandbox Code Playgroud)

我已经六个月没有碰电脑或编程了。我记得六个月前我就能做到。也许是因为 6 个月前我有一个扩展(也许是 RLS?)调用了该行为,但现在没有。

如何在 Rust 和 VSCode 中以换行符继续文档字符串?


VSCode 和扩展

  • VSCode 1.53.0
  • Rust 扩展(包)0.0.3
  • 铁锈 0.7.8
  • Rust 分析仪 0.2.481

其他

  • rustc 和货物 1.49.0
  • rust-analyzer(由 Rust 分析器扩展提供)提交 336909b

rust visual-studio-code

1
推荐指数
1
解决办法
751
查看次数

调试在 VS code 中不起作用。将 php 版本从 7.2 升级到 7.4 后

我已将 PHP 版本从 7.2 升级到 7.4,发现所有项目的调试都已停止。

我的配置是-

zend_extension="/usr/lib/php/20190902/xdebug.so"
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000
Run Code Online (Sandbox Code Playgroud)

我已在以下文件中添加了上述配置 -

  • /etc/php/7.4/apache2/php.ini
  • /etc/php/7.4/apache2/conf.d/20-xdebug.ni
  • /etc/php/7.4/cli/conf.d/20-xdebug.ni
  • /etc/php/7.4/mods-available/xdebug.ini

php -v 命令返回以下输出-

PHP 7.4.14 (cli) (built: Jan 13 2021 08:04:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)

我也在 …

php debugging laravel visual-studio-code php-7.4

1
推荐指数
1
解决办法
1028
查看次数

VSC:不支持或定义 HTML 语言

类型:HTML

在 Visual Studio Code 页面上,我编写了一些 HTML 代码(我将其链接到一个单独的 CSS 文件,尽管我认为这与我的问题没有任何关系),当我单击“运行代码”按钮时,我会看到并显示消息“不支持或定义代码语言”。

我将语言设置为 HTML,而不是“自动检测”

在错误消息下,它显示源是“Code Runner(扩展)”

我已禁用并卸载/重新安装此扩展并重新启动 VSC 多次。

我安装了其他扩展,但不完全确定如何使用它们来“运行”代码。

我读过“确保每种语言的执行程序路径都在环境变量中设置”,但我不完全确定如何做到这一点。

macOS Catalina 10.15.7

VSC 版本 1.53.2

我有 Google Chrome 和 Safari 浏览器。

html visual-studio-code

1
推荐指数
1
解决办法
9642
查看次数

在此版本中,标记“&amp;&amp;”不是有效的语句分隔符,C++ 错误

我在 Visual Studio Code 中运行 C++ 代码时遇到错误,我无法在编辑器中运行任何代码,这里是我多次搜索此问题但没有得到任何结果的错误图像。我尝试使用“|” 代替 '&&' 但仍然没有任何改进。我的 VS Code 是最新的。有人愿意分享一些解决这个问题的方法吗?似乎“#include <bits/stdc++.h>”文件中有错误,因为它说第 1 行和 char 46、char 51 等有错误...

这是错误的图像

任何有关此的信息将不胜感激,感谢您的宝贵时间...

powershell visual-studio-code

1
推荐指数
1
解决办法
5151
查看次数

Mac OS - VS Code Insiders - Code Runner:arm64 架构的未定义符号

过去一周我一直被这个问题困扰。当我使用 VS Code Insiders - Code Runner Extension 或命令: clang++ -std=c++14 main.cpp 编译代码时,出现以下错误:

Undefined symbols for architecture arm64:
  "LinkedList::insertHead(int)", referenced from:
      _main in main-6d6a24.o
  "LinkedList::insertTail(int)", referenced from:
      _main in main-6d6a24.o
  "operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, LinkedList const&)", referenced from:
      _main in main-6d6a24.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

但是,我能够使用下面的 Makefile 编译代码:

all: main

main: main.o linkedList.o
    clang++ -std=c++14 -o $@ $^

main.o: main.cpp linkedList.h
    clang++ -std=c++14 -c …
Run Code Online (Sandbox Code Playgroud)

c++ linker c++11 visual-studio-code apple-silicon

1
推荐指数
1
解决办法
2万
查看次数