Abel'Blog

我干了什么?究竟拿了时间换了什么?

0%

vscode

记录vscode的使用技巧。

光标

多行编辑

按住 alt 键,使用左键点击。按住 shift+alt 键,左键拖。

插件

常用的插件

分类 插件名称 说明 备注
markdown Markdown All in One
Markdown PDF
Markdown Preview Enhanced
Markdown Preview Mermaid Support
markdown-formatter
markdownlint 自动检查合法性
Git GitLens
Git History
Git Graph
主体 Material Theme
vscode-icons
WakaTime 统计代码习惯
远程工具 Remote - Containers
Remote - SSH
Remote - SSH: Editing Configuration Files
Remote - WSL
Go Go for Visual Studio Code

Go语言插件

sRrPpQ.png

sRr9fg.png

工作区间

目录清单

1
2
3
4
5
6
7
8
{
"folders": [
{
"name": "bin",
"path": "server\\bin"
}
]
}

调试,附加进程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Process",
"type": "go",
"request": "attach",
"mode": "local",
// "remotePath": "${workspaceFolder:bin}\\Lobby.exe",
"presentation": {
"hidden": false,
"group": "1",
"order": 2
},
"processId": 17984
},
{
"name": "Login.exe",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder:bin}\\Login.exe",
"env": {},
"args": []
}
]
}
}

组合节点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"compounds": [
{
"name": "Build/RunAll",
"configurations": [
// "Login.exe",
"Gateway.exe",
"DBServer.exe",
"Lobby.exe",
"Scene.exe",
"Matcher.exe",
"Level.exe"
],
"presentation": {
"hidden": false,
"group": "1",
"order": 1
},
"preLaunchTask": "buildall",
"stopAll": true,
}
]
}

任务节点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "buildall",
"type": "shell",
"command": "go",
"args": [
"build",
"-gcflags",
"'-N -l'",
// "-race",
"-o",
"${workspaceFolder:bin}",
"./..."
],
"options": {
"cwd": "${workspaceFolder:src}"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
}

c++ 调试实例

launch.json实例。已经在windows 10 WSL 1.0里面尝试过了;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "启动sentinel",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/octopus_svr/build/sentinel/sentinel",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/octopus_svr/build/sentinel",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

导出markdown数学公式无用

操作系统 安装路径
windows %USERPROFILE%\.vscode\extensions
macOS ~/.vscode/extensions
Linux ~/.vscode/extensions

找到插件目录中:

1
2
3
4
5
6
7
8
9
10
11
12
13
.vscode/extensions/yzane.markdown-pdf-1.4.1/template/template.html
在body节点内增加这两行代码;
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
}
});
</script>

连体字

https://blog.csdn.net/LawssssCat/article/details/104304546

Shell 集成无法激活

由于我使用了zsh,最近刷新了版本

推荐字体

推荐使用JetBarinsMono。

JetBrains Mono,Hack, 'Courier New', monospace Font Size 15.

  1. Input Mono
  2. Hack:
  3. Fira Mono:
  4. Jet Brains Mono:
  5. Fira Code:
  6. Droid Sans Mono:
  7. Source Code Pro:

指定c++的版本

指定c++的编译版本

截屏工具

下载地址

obsidian

用于绘制知识库的一种编辑工具。

CodeGeeX

codegeex-官网

 代码自动生成   

 代码智能补全

 代码翻译  

 支持多种语言   

 适配主流IDE

mac系统

control - 组合用来跳转上一个函数

如何跳出控制台

launch.json里面需要配置一下

1
"console": "externalTerminal"

这样设置,将会直接弹出一个默认的console窗口。

remote in linux

1
2
3
4
5
6
# 执行任何的指令都会出现下面的报错:
__vsc_prompt_cmd_original: command not found
# 增加到 .bashrc 里面
# 执行一下这个就好了
unset PROMPT_COMMAND

杀掉 vscode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
./kill_vscode.sh 
#!/bin/bash

# 使用 ps 命令查找包含 "vscode" 的进程,并且使用 awk 提取进程 ID (PID)
vscode_pids=$(ps aux | grep '[v]scode' | grep -v grep | awk '{print $2}')

# 遍历每个进程 ID,使用 kill 命令终止进程
for pid in $vscode_pids
do
kill -9 $pid
echo "Killed process with PID: $pid"
done

echo "All vscode processes have been terminated."

vscode无法golang远程调试的问题

出现的问题:

1
2
closing connection from different user (192.168.0.200:57850): connections to localhost are only accepted from the same UNIX user for security reasons
2024-03-29T11:03:58+08:00 error layer=dap Error accepting client connection: Only connections from the same user that started this instance of Delve are allowed to connect. See --only-same-user.

chatGPT里面推荐需要使用这个方法:

dlv debug --only-same-user=false

1
2
3
4
5
6
7
8
9
10
11
{
"cwd": "${workspaceFolder}/bin",
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
},
"dlvFlags": ["--only-same-user=false"]
}

将机器上的 dlv-工具都重新安装了,恢复正常。

要通过正则表达式查询代码中的全部中文内容,可以使用以下的正则表达式:

1
[\u4e00-\u9fa5]+

解释:

  • [\u4e00-\u9fa5]:匹配任意一个中文字符。Unicode 范围 \u4e00\u9fa5 包含了常用的简体和繁体中文字符。
  • +:匹配前面的字符类一次或多次,以捕获连续的中文字符。

示例

假设你有以下代码片段:

1
2
fmt.Println("你好,世界!")
str := "这是一个测试"

在文本编辑器或代码 IDE 中使用上述正则表达式会匹配并查找出:

  • "你好,世界"
  • "这是一个测试"

使用场景

你可以在以下场景中使用这个正则表达式:

  • 代码编辑器: 使用文本编辑器(如 VSCode、Sublime Text)中的“查找”功能,开启正则表达式模式,并输入这个表达式来查找代码中的中文内容。
  • 编程语言: 如果是在程序中使用,比如 Python、JavaScript、Golang 等,可以通过对应语言的正则表达式库来查找中文字符。以下是一个简单的 Python 示例:
1
2
3
4
5
6
7
8
9
import re

code = '''
fmt.Println("你好,世界!")
str := "这是一个测试"
'''

chinese_content = re.findall(r'[\u4e00-\u9fa5]+', code)
print(chinese_content)

运行此代码会输出:

1
['你好', '世界', '这是一个测试']

这个方法可以帮助你在代码中快速定位所有包含中文的部分。

参考