ubuntu之VScode

2023-05-16

文章目录

  • 0.安装
  • 1.配置中文
  • 2.插件(推荐使用)
  • 3.conda
  • 4.matlab
  • 5.fira字体设置
  • 6.字符显示配置
  • 7.terminal自定义颜色配置
  • 8.环境变量:terminal runner问题
  • 9.复制root用户vscode插件配置
  • 10.单步调试
  • 11.快捷键
  • 12.文件比较
  • 13.vscode自带terminal:Could not connect to display
  • 14.列编辑
  • 15. update
  • 16. 关闭/开启代码缩略图
  • 17. 根据不同文件类型设置诸如tab的长度,insertSpace使能,ruler位置等选项
  • 18. sync settings配置
  • 19. emoji使用
  • 20. Netease cloudmusic使用
  • 21. 自定义配色
  • 其它
  • 问题
    • 1 vscode启动react出现System limit for number of file watchers reached, watch

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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ubuntu之VScode 的相关文章

随机推荐

  • Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file

    Springboot2 3 4 RELEASE报错 xff0c 解决办法 升级jdk到11版本
  • excel 用一列数据生成图表/折线图

    问题描述 该教程适用于该列的长度很长 xff0c 数据量较大不适合鼠标拖动选中的情况 如果有更简单的方法也欢迎小伙伴们在评论区交流补充 操作步骤 1 点一下列上面的标号 即图中的B 2 按住ctrl xff0c 再点一下列的名称 即图中的a
  • ubuntu NVIDIA CC sanity check failed:

    ubuntu NVIDIA CC sanity check failed The C compiler does not appear to be able to create object files Please make sure y
  • Zeal -- 一款面向软件开发人员的离线文档浏览器

    简介 Zeal官网 就我而言 xff0c 经常忘记一些不常用的方法什么的 xff0c 难免需要查询API文档 xff0c 这时候有一个离线的文档浏览器还是很方便的 xff0c 可以集成多种语言文档 xff0c 便于查阅学习 对于 对于MAC
  • markdown-it 重定义渲染规则

    使用 markdown it 解析 markdown 代码 从这篇文章中了解到 markdown it 解析 markdown 代码的过程 xff0c 了解 token 和渲染规则 add target 61 34 blank 34 to
  • 马走日算法-回溯

    马走日算法 回溯 1 马走日走到目标节点最少的步数 include lt iostream gt include lt queue gt include lt functional gt include lt stack gt includ
  • MYSQL如何设置大小写敏感

    linux下mysql设置大小写不敏感 1 linux下mysql安装完后是默认 xff1a 区分表名的大小写 xff0c 不区分列名的大小写 xff1b 2 用root帐号登录后 xff0c 在 etc my cnf 中的 mysqld
  • Linux下几种图形化远程工具推荐

    好久没写文章了 xff0c 和大家聊聊最近在机器人调试中用到的几款远程桌面工具吧 在机器人调试过程中经常需要使用rviz之类的工具来查看机器人的运行状态 xff0c 图形化的远程工具必不可少 当然如果大家习惯用ssh或者没有图形化方面的需求
  • Win10x64-WDM设备驱动开发入门 - 第六章 VMware-Win10x64+WDK10+VS2015/2019环境搭建与双机调试

    VMware Win10x64 43 WDK10 43 VS2015 2019环境搭建与双机调试 1 驱动程序的开发语言选择调用约定运行时函数的调用 2 配置驱动开发环境1 vs2015 43 SDK 43 WDK10查看 win10 的版
  • 找出4*5矩阵中值最小和最大元素,并分别输出其值及所在的行号和列号 java

    package 矩阵 import java util Scanner public class 矩阵 public static void main String args TODO Auto generated method stub
  • 将python程序打包成exe可执行文件

    方法一 xff1a xff1a 打包完成后可以直接被他人使用 xff0c 他人不用安装python环境的 可以使用pyinstaller模块实现将python项目打包成exe执行文件 span class token triple quot
  • latex 如何在overleaf中插入算法伪代码

    问题描述 博主今天在用overleaf写论文 xff0c 急需插入伪代码 xff0c 将查阅结果记录在此以便后续参考 解决方案 overleaf有专门的说明文档来教大家如何正确插入伪代码 xff1a https www overleaf c
  • 手把手教你一整套R语言数据分析+建模流程

    手把手教你一整套R语言数据分析 43 建模流程 Intro项目背景前期准备数据描述数据清洗预分析及预处理数值型数据类别型数据 特征建模模型对比 Intro 近期在整理数据分析流程 xff0c 找到了之前写的一篇代码 xff0c 分享给大家
  • (工具技巧) —— Visual Studio Code页面放大缩小和字体的调整方式

    文章目录 Visual Studio Code页面放大缩小和字体的调整方式使用方式个人格言 Visual Studio Code页面放大缩小和字体的调整方式 使用方式 在日程的使用过程中 xff0c 有需要对Visual Studio Co
  • Centos7.8 安装 openldap+phpldapadmin 最详细步骤

    本文借助很多网上知识 做一个汇总 xff0c 并且自己手动一步步安装 很多openldap安装都是0几年的安装方式 xff0c 下面给大家演示我一步步安装的详细过程 xff0c CentOS7系统安装就不做演示了 xff0c 直接开肝 这里
  • Apache配置中文说明

    APACHE的配置 xff08 中文 xff09 基于 NCSA 服务的配置文件 这是Apache服务器主要配置文件 它包含服务器的影响服务器运行的配置指令 参见以取得关于这些指令的详细信息 不要只是简单的阅读这些指令信息而不去理解它 这里
  • ubunut 18.04安装xrdp及pulseaudio-module-xrdp

    1 桌面环境 sudo apt install xfce4 2 xrdp服务 sudo apt install xrdp 参考 xff1a xrdp 3 远程声音重定向 确认pulseaudio版本为11 1 pulseaudio vers
  • ios8 新的AlertView

    转自cocoachina OS 8的新特性之一就是让接口更有适应性 更灵活 xff0c 因此许多视图控制器的实现方式发生了巨大的变化 全新的UIPresentationController在实现视图控制器间的过渡动画效果和自适应设备尺寸变化
  • Debian 系统时间配置(NTP)

    系统时间NTP和RTC同步 xff0c Debian的时区配置 系统及架构 xff1a Linux Matrix 061001 5 10 42 yocto standard 1 Thu Jun 3 07 00 52 UTC 2021 arm
  • ubuntu之VScode

    文章目录 0 安装1 配置中文2 插件 xff08 推荐使用 xff09 3 conda4 matlab5 fira字体设置6 字符显示配置7 terminal自定义颜色配置8 环境变量 xff1a terminal runner问题9 复