ubuntu之VScode


VSCode使用之后,瞬间就爱上了此款编辑器

0.安装

在Ubuntu软件中心,直接搜索Visual Studio Code

传送门

# offline
sudo dpkg -i code_1.25.1-1531323788_amd64.deb
#sudo apt --fix-broken install ./code_1.25.1-1531323788_amd64.deb
 
# online
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code


code  #打开vscode软件

1.配置中文

参考:https://blog.csdn.net/hellozex/article/details/80763558
或者
安装简体中文插件
Chinese (Simplified) Language Pack for Visual Studio Code

2.插件(推荐使用)

参考:
https://blog.csdn.net/maixiaochai/article/details/90767129
https://www.cnblogs.com/zzsdream/p/6592429.html
https://www.cnblogs.com/sybboy/p/8989342.html

插件名称:
Python
python snippets

Word Count CJK #文字统计

Sort lines
Better Align
vscode-pdf

vscode-icons
Material Icon Theme #推荐

Settings Sync #推荐

SVG 推荐
SVG Viewer (不推荐,有bug)

Code Spell Checker
path-intellisense
Bracket Pair Colorizer
Todo Tree
Indent-Rainbow
Code Runner
python snippets
python test使用参考:https://blog.csdn.net/anguuan/article/details/104782857
filesize
leetCode
Markdown+Math #latex专业公式插件
Markdown All in One #设置Markdown › Extension › Math: Enabled ->不够选Enable basic math support (Powered by KaTeX).,会选用Markdown+Math专业公式
markdownlint
Foam #markdown写书插件
Markdown Preview Enhanced
Markdown PDF #将markdown文档成才pdf格式文档
Markdown TOC #自动生成目录安装使用教程参考
markdown画图插件 Mermaid各种类型的画图
使用问题参考
Hex Editor #vs code 以16进制格式查看文件

打开用户设置之后在搜索设置里面搜索Eol。
找到文件的Eol可以看到默认行尾字符设置为auto --> 改成 \n 即可 自动生成目录不对齐问题。

#md转pdf依赖包     
sudo apt-get install calibre   #功能ebook->PDF
#ubuntu18 install chrome   #功能Chrome
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb   #下载
sudo apt install ./google-chrome-stable_current_amd64.deb #安装

md文件画流程图,推荐使用dot画图
md文件内容如下

···dot  #注意 ...替换为```字符
digraph NetFlow {
    Left->FeatureL[label=FeatureNet];
    Right->FeatureR[label=FeatureNet];
    {FeatureL,FeatureR}->CostVolume[style=bold,color=red];
    edge [color=blue];
    CostVolume->Aggregation;
    Aggregation->Estimation;
    Estimation->Refinement
    Refinement->Disp;

    Refinement[shape=box,fontcolor=red];
    Disp[color=red];
}
···

Git History
GitLens — Git supercharged

Material Theme
Slack Theme #推荐
Tiny Light #推荐 护眼(绿色为主),其它都是黑色主题,时间长了容易眼痛
Peacock # 推荐 可以随机产生不同颜色的主题
#推荐使用方法:Tiny Light为主色调,Peacock为辅助色调(peacock:Surprise Me With Random Color)

Matlab
Matlab Code Run
Matlab Snippets
matlab-formatter

Emoji Code

#完美文档工具
Latex
#参考 Ubuntu 18.04配置latex+VS code
https://blog.csdn.net/u014454538/article/details/104501611
编译.tex文件->pdf Ctrl+Alt+B
vscode setting.json配置如下

    "latex-workshop.latex.recipes": [
        {
            "name": "xelatex",
            "tools": ["xelatex"]
        },
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": ["xelatex", "bibtex", "xelatex", "xelatex"]
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": ["%DOCFILE%"]
        }
    ],
    "latex-preview.command": "xelatex",
    "latex-workshop.view.pdf.viewer": "tab" 

latex+vscode其他配置:https://blog.csdn.net/liu6tot/article/details/104243625

vscode SSH #推荐 config参考
安装如下插件
Remote-SSH
Remote-SSH:Editing Configuration Files
配置如下:

vim ~/.ssh/config
#写入
Host 1080ti
    HostName 192.168.3.xxx
    User username

即可直接使用,连接过程中需要输入ssh登陆的password

PlantUML #画图插件,系统环境依赖,java安装包:sudo apt-get install openjdk-8-jdk
Graphviz Preview 依赖插件

Draw.io Integration #推荐, 有了此插件,基本功能上可以和visio拜拜了

将 VS Code 打造成一个体验舒适的 Markdown 编辑器

3.conda

File->Preference->Python: Conda Path:/home/$(user-name)/miniconda3

4.matlab

  • 1 插件 matlab
  • 2 settings
    -vscode -> File -> preferences -> search word: matlab
    Matlab: Matlabpath
    /usr/local/MATLAB/R2018a/bin/matlab
    Matlab: Mlintpath
    /usr/local/MATLAB/R2018a/bin/glnxa64/mlint
  • 3 插件 matlab-formatter
    用于整理规范matlab代码

5.fira字体设置

系统安装fira字体

# ubuntu18 
sudo apt-get update
sudo apt-get install fonts-firacode
# windows10 on power shell 管理员
#Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install firacode

File->Preference->Text Editor->Font

"editor.fontFamily": "Fira Code",//后边的引号中写上要设置的字体类型,个人比较喜欢Fira Code
"editor.fontLigatures": true,//这个控制是否启用字体连字,true启用,false不启用,这里选择启用
"editor.fontSize": 14,//设置字体大小
"editor.fontWeight": "normal",//这个设置字体粗细,可选normal,bold,"100"~"900"等,选择合适的就行

6.字符显示配置

一直显示空格符号
File->Preference->Editor: Render Whitespace:all
改成false目的是:不要检测到第一个是tab,就后面都用tab,这样会覆盖默认设置。
Editor: Detect Indentation: false,
显示tab符
Editor: Render Control Characters: yes

7.terminal自定义颜色配置

参考:https://www.jianshu.com/p/20311e5dc104

"workbench.colorCustomizations": {
       // "editor.background": "#1f1f2c",
       // "editorGutter.background": "#1d1f2e"
       "terminal.background":"#FFFFFF",
       "terminal.foreground":"#333333",
       "terminalCursor.background":"#333333",
       "terminalCursor.foreground":"#333333",
       "terminal.ansiBlack":"#FFFFFF",
       "terminal.ansiBlue":"#795DA3",
       "terminal.ansiBrightBlack":"#969896",
       "terminal.ansiBrightBlue":"#795DA3",
       "terminal.ansiBrightCyan":"#183691",
       "terminal.ansiBrightGreen":"#183691",
       "terminal.ansiBrightMagenta":"#A71D5D",
       "terminal.ansiBrightRed":"#ED6A43",
       "terminal.ansiBrightWhite":"#FFFFFF",
       "terminal.ansiBrightYellow":"#795DA3",
       "terminal.ansiCyan":"#183691",
       "terminal.ansiGreen":"#183691",
       "terminal.ansiMagenta":"#A71D5D",
       "terminal.ansiRed":"#ED6A43",
       "terminal.ansiWhite":"#333333",
       "terminal.ansiYellow":"#795DA3"
    },

其它配色方案:
https://glitchbone.github.io/vscode-base16-term/#/
个人喜好:Material 系列配色方案

8.环境变量:terminal runner问题

code runner 使用是出现

[Running] python -u "/home/tt01/work/dbsr/tempCodeRunnerFile.py"
/bin/sh: 1: python: not found

[Done] exited with code=127 in 0.011 seconds

问题背景:conda python + vscode + code runner
解决方式:现在终端上激活conda python环境,然后是终端输入code命令(打开vscode)

9.复制root用户vscode插件配置

su xxx
cd 
cp -r /home/root/.vscode .

10.单步调试

参考官网
参考官网Linux C++配置

Ubuntu下Vscode调试出现无法打开"libc-start.c"
在gnu官网找到对应的glibc下载解压到/build/xxx对应文件中

参考:https://www.jianshu.com/p/4b905372cdc6
在c/c++项目下的.vscode目录,保证有如下文件:

  • c_cpp_properties.json 配置头文件包含
  • launch.json 配置运行环境
  • tasks.json 配置调试环境
  • settings.json (可选)本工程的vscode自定义配置

c/c++ tasks.json文件内容如下

{
    "version": "2.0.0",
    // "tasks": [
    // 	{
    // 		"type": "cppbuild",
    // 		"label": "C/C++: gcc build active file",
    // 		// "command": "/usr/bin/gcc",
    // 		"command": "make solution=debug",
    // 		"args": [
    // 			"-g",
    // 			"${file}",
    // 			"-o",
    // 			"${fileDirname}/${fileBasenameNoExtension}"
    // 		],
    // 		"options": {
    // 			"cwd": "${workspaceFolder}"
    // 		},
    // 		"problemMatcher": [
    // 			"$gcc"
    // 		],
    // 		"group": {
    // 			"kind": "build",
    // 			"isDefault": true
    // 		},
    // 		"detail": "compiler: /usr/bin/gcc"
    // 	}
    // ]

    "tasks": [
        {
            "label": "debug",
            "type": "shell",
            "command": "make",            //shell 命令
            "args": ["solution=debug"],   //shell 命令参数, 需要配合makefile文件接口
            "group": {                    //vscode  Ctrl+Shift+B快捷键调出的快捷菜单
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": ["$gcc" ],
            //关闭烦人的提示"Terminal will be reused by tasks, press any key to close it."
            "presentation": {
                "reveal": "silent",
                "clear": true
            }
        },
        {
            "label": "release",
            "type": "shell",
            "command": "make",
            "args": ["solution=release"],
            "group": {                  
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": ["$gcc"],
            "presentation": {
                "reveal": "silent",
                "clear": true
            }
        },
        {
            "label": "clean",
            "type": "shell",
            "command": "make",
            "args": ["clean"],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [ ],
            "presentation": {
                "reveal": "silent",
                "clear": true
            }
        }        
    ]
}

c/c++ launch.json文件内容如下

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "(gdb) Launch",
			"type": "cppdbg",
			"request": "launch",
			// "program": "enter program name, for example ${workspaceFolder}/a.out",
			"program": "${workspaceFolder}/prj/main.exe",  //可执行程序入口
			// "args": ["spr.mbt"],                        //可执行程序参数
			"args": ["-l=0.141"],                          //可执行程序参数
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}/prj",               //起始位置
			"environment": [],
			"externalConsole": false,
			"MIMode": "gdb",
			"setupCommands": [
				{
					"description": "Enable pretty-printing for gdb",
					"text": "-enable-pretty-printing",
					"ignoreFailures": true
				}
			]
		}
	]
}

ctrl+shift+P打开Command Palette,运行C/Cpp: Edit configurations…生成c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/include/",
                "/usr/local/include/opencv4"  //opencv路径
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}
#编译
Ctrl+Shift+B
#调试
F5 or from the main menu choose Run > Start Debugging

python task.json文件配置不需要,需要 launch.json文件配置,如下

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Python: Current File",
			"type": "python",
			"request": "launch",
			"program": "${file}",
			"console": "integratedTerminal"
		}
	]
}

11.快捷键

官方参考
参考

12.文件比较

参考:https://blog.csdn.net/qq_41151638/article/details/79650141

13.vscode自带terminal:Could not connect to display

解决方法

#解决方案很简单:
export DISPLAY=':0.0'
#如果不行的话则尝试
export DISPLAY=':1.0'或export DISPLAY=':2.0'
#至于何时为1.0或2.0或0.0,可以在终端执行:
echo ${DISPLAY}
#显示的是什么配置成什么就行了
#启动时自动设置,如下修改配置文件
vim ~/.bashrc
export DISPLAY=':0.0'

14.列编辑

参考博客

  1. 多光标插入功能
    Alt+鼠标左键,添加多光标输入 #only windows
  2. 列选择
    Shift+Alt+鼠标左键拖动,选中拖动的区域内容 #windows+linux

15. update

避免每次去官方下载手动安装的麻烦

wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O ~/Downloads/code_latest_amd64.deb
sudo dpkg -i ~/Downloads/code_latest_amd64.deb

16. 关闭/开启代码缩略图

vsCode配置代码缩略图:
  文件–>首选项–>设置–>搜索 minimap --> true 打开 false 关闭

17. 根据不同文件类型设置诸如tab的长度,insertSpace使能,ruler位置等选项

    "[C_CPP]": {
        "editor.tabSize": 4,
        "editor.insertSpaces": true
    },

    "[Makefile]": {
        "editor.tabSize": 4,
        "editor.insertSpaces": false
    },

18. sync settings配置

  • 注册要有github账户
  • github -> New gist -> create: 把gist id号copy,以备后续使用
  • github -> Settings -> Develop Settings -> Personal access tokens -> Generate new token: 把token字符串copy,以备后续使用
  • vscode -> ctrl + shift + p -> sync: Advance option -> sync: open settings -> 把 gist id号和token字符串填写如对于位置 -> 回车

使用:

  • 常服务器 vscode 填入gist + token -> sync: update/upload
  • 其它服务器 vscode 填入 gist -> sync: Download

19. emoji使用

参考:在markdown中插入emoji表情

20. Netease cloudmusic使用

VSC Netease Music,找到插件,install即可
先登陆:建议手机号直接注册,随机秘密,然后登陆
ctrl+shift+p 输入 cloudmusic,点开start

21. 自定义配色

theme-color官网参考(非常详细)
建议关注:editor.tokenColorCustomizations 的选项配置进行自定义配置,自定义配置内容写入settings.json即可,其它使用主题插件解决
Customize Colors in Global Setting示例
C/C++ Naming Conventions所有自定义支持类型

其它

在线文档:https://houdunren.gitee.io/note/

问题

1 vscode启动react出现System limit for number of file watchers reached, watch

参考

需要在vscode下修改文件监控数
解决 bug System limit for number of file watchers reached, watch

sudo vi /etc/sysctl.conf
# 在最后面加入
fs.inotify.max_user_watches=524288
# 保存后推出
# 之后运行命令
sudo sysctl -p
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿尔发go

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值