一、linux笔记本屏幕休眠
setterm --blank 1
一分钟内无操作自动关闭屏幕
二、VSCODE windows和linux下的C/C++配置
1.windwos下:
三个文件:
第一个文件:c_cpp_properties.json
内容为:
{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "D:\\mingw64\\bin\\gcc.exe", /*修改成自己bin目录下的g++.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
第二个文件:lanch.json
内容为:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe", /*修改成自己bin目录下的gdb.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++"
}
]
}
第三个文件:tasks.json
内容为:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "task g++",
"command": "D:\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: D:\\mingw64\\bin\\g++.exe"
}
]
}
有一点需要注意的是,如果你的task.json是自动生成的,那么请注意,参数““label”: “task g++”,”必须和lanch.json文件中的 “preLaunchTask”: “task g++” 保持一致,否则会出现“could not find the task g++”的错误提示!
2.linux下
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "compile",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [{
"label": "compile",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
注意,C的编译需要将g++改成gcc,另外如果没有安装gdb会报‘please specify the midebugger’的错误,需要安装一下gdb
3.用vscode远程连接服务器,隐藏文件
使用vscode连接的时候,会出现linux下的隐藏文件,例如.bashrc .cach等,或者一些其他的不需要的文件夹,可以使用文件排除的功能
左下角设置-搜索file.exclude 添加排除规则,例如排除.开头的文件,可以使用**/.**即可
三、VSCODE 主题配置
主题:Dracula
设置搜索workbench.colorCustomizations,然后打开settings.json设置文件
写入以下配置:
{
"bracket-pair-colorizer-2.depreciation-notice": false,
"tabnine.experimentalAutoImports": true,
"remote.SSH.remotePlatform": {
"192.168.3.105": "linux",
"211.159.223.17": "linux",
"114.219.91.73": "linux",
"49.85.205.212": "linux",
"117.80.11.94": "linux"
},
"cmake.configureOnOpen": true,
"workbench.startupEditor": "none",
"debug.onTaskErrors": "abort",
"editor.formatOnType": true,
"kite.showWelcomeNotificationOnStartup": false,
"explorer.confirmDelete": false,
"files.exclude": {
"**/.**": true
},
"hexeditor.columnWidth": 32,
"hexeditor.showDecodedText": false,
"hexeditor.defaultEndianness": "little",
"hexeditor.inspectorType": "aside",
"git.autofetch": true,
"workbench.colorTheme": "Dracula",
"editor.fontFamily": "Roman 常规, 'Courier New', monospace",
"editor.fontSize": 16,
"debug.allowBreakpointsEverywhere": true,
"window.zoomLevel": -1,
"editor.cursorSmoothCaretAnimation": true,
"editor.cursorWidth": 2,
"editor.mouseWheelZoom": true,
"workbench.colorCustomizations": {
// "editor.selectionHighlightBackground": "#288603",
// "editor.selectionBackground":"#288603",
"editor.selectionHighlightBorder": "#ffffff"
}
// "files.exclude": {
// "**/.git": true,
// "**/.svn": true,
// "**/.hg": true,
// "**/CVS": true,
// "**/.DS_Store": true,
// "**/Thumbs.db": true,
// "**/.*":true
// }
}