Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

VSCODE安装

通用界面安装

  • 先下载安装 vscode 点击下载,点击 download for windows,下载exe安装文件,一路next安装完成。
  • 打开vscode,默认是英文界面,如果英文不好希望使用中文界面,可以安装中文插件,在上面输入 chinese,点击选中第一个 chinese(simplified)language,安装插件,重启后界面变为中文,方便使用。

Centos命令行安装

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

on older versions using yum:
yum check-update
sudo yum install code

Fedora 22 and above using dnf:
dnf check-update
sudo dnf install code

参考来源

基本设置

中文语言设置

快捷键 Ctrl+Shift+p
输入 configure display language,选择相应的语言,然后重启 vscode 即可。

设置自动换行

file-> preferences -> user settings: wordWrap设置为on

快捷键

img

  • 基础编辑 basic editing
快捷键组合 功能
ctrl+k ctrl+v 预览
alt + shift + 鼠标左拖 列选择
ctrl + shift + E 资源管理器
ctrl+k ctrl+c ctrl+k ctrl+u or ctrl+/ 注释
ctrl + shift +p 选择解释器

Markdown 配置

为了使用提供对 markdown 的支持,需要安装两个插件,Markdown All in oneMarkdown Preview Enhanced。第一个插件提供了基本的对markdown语法的支持,第二个插件使我们能在vscode中预览markdown文件的效果

参考文献:

  1. 知乎

linux python配置

1
2
3
ctrl+shift+s, python
sudo apt-get install python-pip
pip install pylint

或conda环境设置好,vscode直接选择编译器即可。

Error: “Visual Studio Code is unable to watch for file changes in this large workspace” (error ENOSPC)

1
2
3
4
cat /proc/sys/fs/inotify/max_user_watches
sudo cp /etc/sysctl.conf /etc/sysctl.conf_backup
fs.inotify.max_user_watches=524288
sudo sysctl -p

Windows python 配置

vscode在windows下配置python环境

1
2
3
4
5
6
7
8
9
10
11
12
% 1. install python 
install python3.7 % with environment path
% 2. plugin microsoft
Ctrl+Shift+X, python % plugin
% 3. select interpreter
Ctrl+Shift+P, Python: Select Interpreter
% 4. virtualEnviroment
py -3 -m venv env
env\scripts\activate
python -m pip install matplotlib
% 5. run
F5, Debug

两个问题:

  1. 无法加载文件 activate.ps1,因为在此系统上禁止运行脚本
    power shell 管理员身份运行 {\color{blue}set-ExecutionPolicy RemoteSigned},选择 Y
  2. 无法使用建立的虚拟环境,提示 import 失败
    在 setting 下,添加一行
    “python.linting.pylintPath”: “env\Scripts\pylint.exe”

REF

latex 配置

Latex 通用设置, REF

魔术命令:

1
2
% !TEX program = xelatex\\
% !TEX root = ../elegantbook-cn.tex

正反向搜索:

  1. 在 LaTeX 文件中,按 Ctrl + Alt + J 跳转到对应的 PDF 文件位置.
  2. 在 PDF 文件中,按下 Ctrl + ← 同时鼠标单机,跳转到对应的 LaTeX 文件位置.

快捷键:

  1. 命令面板: ctrl+shift+p, 或 在任意地方单机右键
  2. 添加编译工具,添加编译方案

禁止保存自动编译:

1
"latex-workshop.latex.autoBuild.run": "never",

linux下latex安装配置},参考文献1, 参考文献2

编译快捷键设置

1
快捷键 ctrl+,搜索 recipes,设置为 Ctrl+r,搜索latex将预览设置为Ctrl+1

vscode linux latex 配置

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% settings.json for latex-workshop
{
"window.zoomLevel": 1.5,
"editor.fontSize": 16,
"latex-workshop.view.pdf.viewer": "tab",
"editor.wordWrap": "on"
}

% texlive 2019 environment
export PATH=/usr/local/texlive/2019/bin/x86_64-linux:$PATH
export MANPATH=/usr/local/texlive/2019/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2019/texmf-dist/doc/info:$INFOPATH

% settings.json under folder
{
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "xe->bib->xe->xe",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.autoBuild.run": "never",
}

c++配置

首先安装vscode,安装c/c++插件,mkdir cpp, 把days.cpp复制到cpp目录下,打开vscode。以下是配置步骤:

配置c++ IntelliSense

使用F1,打开命令选项,输入 c/c++

选择C/C++:Edit configuration,生成c_cpp_properties.json配置文件。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

配置launch.json

在debug界面中选择添加配置,然后选择才c++(gdb/lgdb)选项,生成launch.json 顾名思义此文件主要服务于调试时的加载控制

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
30
31
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。

"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false, //设为false时使用集成终端,true为外置终端
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}

配置tasks.json

在命令窗口中输入task,选择task: configure task选项生成tasks.json文件

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    "version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-Wall",
"-std=c++17",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"presentation": { //控制终端显示
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
},
{
"label": "run",
"type": "shell",
"dependsOn": ["build"],
"command": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"presentation": { //控制终端显示
"echo": false,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
//"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
}
}
]
}

按下F5开始调试吧,一切就是这么简单,开始美好的旅程。

步骤参考 REF},代码参考 REF

VS2015打包

参考文献:VS2015打包程序发布 – 52117354 – 博客园 (cnblogs.com)

DevExpress 安装并添加到VS工具箱中

参考文献:藏歌倾城

WSL 下的开发调试

在 Windows 上安装过程中务必:

  1. 安装至 C 盘(否则会有路径与访问权限的问题)
  2. 在「选择其他任务」界面勾选「其他」下的全部四个选项(为了后面在 WSL 中直接调用 code 命令来打开 Visual Studio Code 打下基础。)

在 Windows 文件夹与文件中出现的名字不能有特殊符号,包括 Emoji,否则会出现无法识别 WSL 中的 Git 路径和无法打开终端直接进入相应文件夹的问题。

Remote-WSL 插件

需要了解的重要的一点是:VS Code 在 Remote 插件下的使用和在本机下的使用实际上是两个环境,插件系统并不共享。因此,我们一旦开启了 WSL 的 Remote 环境,所下载的插件也都是在这个环境下才能使用的。

REF

连接远程服务器开发

为什么用VScode连接远程服务器开发?

连接远程服务器的方法有很多,比如可以借助XShell、putty等软件使用ssh命令来登录远程服务器。但如果使用这种连接方法在远程服务器上进行开发工作,会来带诸多不便,比如:

全程只能在终端使用指令操作,文件操作麻烦。
写代码不方便,我们可能会先在本地写好代码再使用scp指令把源代码传送到服务器再运行,或直接在服务器上使用Vim或Vi进行编辑,这些操作起来我个人觉得都不顺手。
服务器上的图片无法查看,比如有时候我们的程序最后输出一些图片,我们在终端上无法查看,还要传回本地才能看到。
使用VScode能够很好的解决以上问题,VScode连接服务器后的方便程度和本地开发几乎没有差别!在VScode中编辑代码直接同步更新到服务器上,可以用鼠标在文件目录对文件进行操作,可以查看图片。

安装OpenSSH
该服务的作用是让你可以在终端使用ssh指令,Windows10 通常自带OpenSSH 不需要安装。

Windows10下检查是否已经安装OpenSSH的方法:

按下快捷键Win + X,选择Windows PoweShell(管理员),输入以下指令:
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
如果电脑未安装OpenSSH,则State会显示NotPresent

如果未安装,则输入指令:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

安装Remote-SSH
Remote-SSHVScode的插件,安装完VScode以后,直接在插件中搜索ssh,即可找到Remote-SSH,点击install安装。

配置Remote-SSH
安装完Remote-SSH以后左侧会出现一个远程资源管理的图标,选择SSH Targets,进入config配置文件

在配置文件中设置服务器信息,输入HostNameUser,保存以后左侧会出现对应机器名称。

更改设置,File->Preferences->Settings->Extension->Remote-SSH,找到Show Login Terminal并勾选。

连接服务器
点击SSH TARGETS下的服务器旁边的按钮纽行连接,弹出让你输入密码:

在这里可能会弹出让你选择服务器的平台,需要选择以后才会出现输入密码的步骤

成功连上服务器,点击有右侧的+号创建服务器的终端窗口,可以正常使用了!

我们还可以打开服务器的文件夹

打开以后可以看到服务器文件目录,直接在文件目录中选择文件进行编辑,实时同步到服务器上,这时候已经可以开始愉快的进行开发了,开发体验媲美本地开发!

通过跳板机连接服务器
有时候我们需要跳板机来连接服务器,也即先连接一台跳板机服务器,然后通过这台跳板机所在的内网再次跳转到目标服务器。最简单的做法就是按上述方法连接到跳板机,然后在跳板机的终端用ssh指令跳转到目标服务器,但这样跳转后,我们无法在VScode中打开服务器的文件目录,操作起来很不方便。我们可以把config的设置改成如下,就可以通过hky跳板机跳转到gpu了:

1
2
3
4
5
6
7
8
9
Host hky
HostName xxx.xxx.xxx.101(跳板机IP)
User lyfeng

Host gpu
HostName xxx.xxx.xxx.3(内网地址)
User lyfeng
ProxyCommand "openssh的安装路径\ssh.exe" -W %h:%p -q hky
# 连接hky, 再通过hky的局域网ssh到gpu

openssh的安装路径因人而异(我这里是C:\Windows\System32\OpenSSH\ssh.exe

参考来源:知乎

GSF IDL 开发

  • axios的安装和使用
    npm install axios -g
    参考文献 breezAm

评论