【vscode】打造你的嵌入式开发环境(STM8)

vscode十分的轻量化,本身扩展也很多。本文主要安利一款非常好用的插件,支持IAR和KEIL,同时分享一些不错的扩展,让你的嵌入式开发快起来。

准备工作

vscode
iar for stm8
stvp

主菜

EIDE手册
国人作者的项目,相当的不错,如果是万事俱备只欠东风的小伙伴,点进去学习就可以了,下文主要针对首次使用vscode的小伙伴。

扩展

Better Align
顾名思义,更好的对齐代码,让你的代码更美观

Bracket Pair Colorizer
1
让你的括号色彩斑斓,成双成对

C/C++
C++ Intellisense
C语言开发必备

Chinese (Simplified) Language Pack for Visual Studio Code
中文支持包

Comment Translate
使用谷歌翻译的API,看源码的注释时相当舒适

Github
提交/拉取你的代码仓库
速度慢的,hosts文件内添加如下文本,基本上可以满足使用

# GitHub Start 
140.82.113.3      github.com
140.82.114.20     gist.github.com
185.199.110.153   github.github.io
151.101.184.133    assets-cdn.github.com
151.101.184.133    raw.githubusercontent.com
151.101.184.133    gist.githubusercontent.com
151.101.184.133    cloud.githubusercontent.com
151.101.184.133    camo.githubusercontent.com
151.101.184.133    avatars0.githubusercontent.com
199.232.68.133     avatars0.githubusercontent.com
199.232.28.133     avatars1.githubusercontent.com
151.101.184.133    avatars1.githubusercontent.com
151.101.184.133    avatars2.githubusercontent.com
199.232.28.133     avatars2.githubusercontent.com
151.101.184.133    avatars3.githubusercontent.com
199.232.68.133     avatars3.githubusercontent.com
151.101.184.133    avatars4.githubusercontent.com
199.232.68.133     avatars4.githubusercontent.com
151.101.184.133    avatars5.githubusercontent.com
199.232.68.133     avatars5.githubusercontent.com
151.101.184.133    avatars6.githubusercontent.com
199.232.68.133     avatars6.githubusercontent.com
151.101.184.133    avatars7.githubusercontent.com
199.232.68.133     avatars7.githubusercontent.com
151.101.184.133    avatars8.githubusercontent.com
199.232.68.133     avatars8.githubusercontent.com

# GitHub End

vscode-pdf
查看你的pdf文件(使用感受不佳)

Settings Sync
同步你的扩展

One Dark Pro
非常好看的主题

注释模板

良好的代码风格离不开注释,vscode支持用户添加自己的代码片段。
具体方法:左下角 管理->用户代码片段->新建全局代码片段文件->命名
之后可以看到如下片段:

{
	// Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {
	// 	"scope": "javascript,typescript",
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
}

修改如下:

{
	// Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	"HEAD": {
		"scope": "c",
		"prefix": "ysy_HEADER",
		"body": [
			"/*************************************************************",
			"Copyright (c) $CURRENT_YEAR Shawn Yan, All rights reserved",
			"-------------------------------------------------------------",
			"File Name: ",
			"",
			"Desc     : ",
			"",
			"Author   : Shawn Yan",
			"",
			"Date     : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
			"",
			"*************************************************************/"
		],
		"description": "My filehead description"
	},
	"Function_Struct": {
		"scope": "c",
		"prefix": "ysy_struct",
		"body": [
			"/*------------------------- Includes -----------------------*/",
			"",
			"",
			"/*----------- Global Definitions and Declarations ----------*/",
			"",
			"",
			"/*-------------------- Type Declarations -------------------*/",
			"",
			"",
			"/*------------------ Variable Declarations -----------------*/",
			"",
			"",
			"/*------------------- Function Prototype -------------------*/",
			"",
			"",
			"/*------------------- Function Implement -------------------*/",
			"",
			"",
			"/*--------------------------- END --------------------------*/"
		],
		"description": "My function struct"
	},
	"Function_Description": {
		"scope": "c",
		"prefix": "ysy_fundesc",
		"body": [
			"/*************************************************************",
			"Function Name       : ",
			"Function Description: ",
			"Param_in            : ",
			"Param_out           : ",
			"Return Type         : ",
			"Note                : ",
			"Author              : Yan",
			"Time                : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
			"*************************************************************/"
		],
		"description": "My function description"
	}
	
}

主要关注scope、prefix、body三项
scope为关联语言,即在c语言的文件中才能被使用
在文件中输入prefix中的内容即可快速打印body中的内容
效果如下

/*************************************************************
Copyright (c) 2020 Shawn Yan, All rights reserved
-------------------------------------------------------------
File Name: 

Desc     : 

Author   : Shawn Yan

Date     : 2020-12-26

*************************************************************/
/*************************************************************
Function Name       : 
Function Description: 
Param_in            : 
Param_out           : 
Return Type         : 
Note                : 
Author              : Yan
Time                : 2020-12-26
*************************************************************/
/*------------------------- Includes -----------------------*/


/*----------- Global Definitions and Declarations ----------*/


/*-------------------- Type Declarations -------------------*/


/*------------------ Variable Declarations -----------------*/


/*------------------- Function Prototype -------------------*/


/*------------------- Function Implement -------------------*/


/*--------------------------- END --------------------------*/

大概就介绍到这里啦,有什么问题欢迎留言!

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值