- 尝试代替source insight4
添加工程:创建一个空项目在一个选定文件夹里;然后把工程代码复制到改文件夹里;然后显示所有文件,并把需要的文件夹包含进项目里。
修改快捷键(注意可以先配置成VSCODE 快捷键风格)
- 删除符号的字符后无法补齐解决方法:Ctrl + j
- 视图–工具栏–自定义–命令–上下文菜单:修改右键菜单
- 设置(工具–选项)–环境–颜色和字体:改颜色
- Visual Assist插件
- 设置–文本编辑器–c/c+±-导航栏
- 安装word Highlight 插件显示选中高亮
- 切换头文件设置名:切换标题代码文件
快速执行命令:
工具–外部工具:
命令:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
参数:需要执行的命令,如py xxx目录\xx.py
勾上使用输出窗口;然后在快捷键给外部n添加快捷键
使用clang-format
将.clang-format放在工程目录下即可
import os
from shutil import copyfile
pfn = 'rtos-lvgl' #工程文件夹名字
s = '' #包含路径字符串
c_files = '' #编译文件名(c和h)
n_files = ' <ItemGroup>\n' #其他文件名
#获取路径名和文件名
def get_filelist(file_name):
global s
s += '$(ProjectDir)\\' + pfn + '\\' + file_name + ';\n' #根据具体工程改路径前缀
for home, dirs, files in os.walk('.\\' + pfn + '\\' + file_name):
for d in dirs: #os.path.join 添加路径
s += (os.path.join(home,d)).replace('.\\', '$(ProjectDir)\\') + ';\n'
#_path = '.\\' + pfn '\\' + file_name 根目录
#get_target_files(_path)
#获取文件名,加上目录下的指定类型文件进工程
def get_target_files(path) :
global c_files, n_files
for home, dirs, files in os.walk(path):
for file in files:
file = (os.path.join(home, file)).replace('.\\', '')
if file.endswith('.c') or file.endswith('.h'):
c_files += " <ClCompile Include=\"" + file + '\" />\n'
elif file.endswith('.cmake') or file.endswith('.txt'):
n_files += " <None Include=\"" + file + '\" />\n'
def bk():
try:
copyfile("./VS-RTOS-LVGL.vcxproj", "./vcxprojBK") #修改对应文件名
except IOError as e:
print("Unable to copy file. %s" % e)
exit(1)
except:
exit(1)
if __name__ == "__main__":
bk()
#根据脚本位置
get_filelist('CORE')
get_filelist('oppo_driver')
get_filelist('FreeRTOSv202104')
get_filelist('HALLIB')
get_filelist('HARDWARE')
get_filelist('SYSTEM')
get_filelist('oppo_hal_platform')
get_filelist('third_party\ThinkSi')
get_filelist('third_party\littlefs')
get_target_files('.\RsWatch\cmake\oppo_system')
c_files += " </ItemGroup>\n"
with open(r'./vcxprojBK', 'r', encoding='utf-8') as f:
#先进去工程随便包含一个目录,以生成相应标签(不同版本VS便签不同)
keyword = '<AdditionalIncludeDirectories>'
keyword2 = '%(AdditionalIncludeDirectories)'
rd = f.read()
post = rd.find(keyword)
post2 = rd.find(keyword2)
rd = rd[:post + len(keyword)] + s + rd[post2:]
#修改对应文件名
with open(r'./VS-RTOS-LVGL.vcxproj', 'w', encoding='utf-8') as ff:
ff.write(rd)
print("OK")
''' 添加文件进工程
keyword = '</ItemDefinitionGroup>\n <ItemGroup>\n'
keyword2 = ' </ItemGroup>\n <Import'
post = rd.find(keyword)
post2 = rd.find(keyword2)
rd = rd[:post + len(keyword)] + c_files + n_files + rd[post2:] '''
snippet:去工具–代码段片断,把base和C++的文件删掉(不是移除,是去目录删掉文件),然后替换cpp.tpl (把<0x0c>替换,参考原cpp.tpl)
<0x0c>
a::nn:
!= 0<0x0c>
a:!= NULL:NN:
!= NULL<0x0c>
a::#d:
#define <0x0c>
a::#en:
#endif<0x0c>
a:#if 0 ... #endif:#if1:
#if 1
$selected$$end$
#endif
<0x0c>
a:#ifdef (VA):#ifd:
#ifdef $condition$$end$
#endif // $condition$
<0x0c>
a:#ifndef ... #endif:#ifn:
#ifndef $condition$$end$
#endif $condition$
<0x0c>
a::#in:
#include "$end$"<0x0c>
a::#inc:
#include <$end$><0x0c>
a::#p:
#pragma <0x0c>
readme:
VA Snippet used by Surround With #region.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:#region (VA):#r:
#pragma region $end$$regionName$
$selected$
#pragma endregion $regionName$
<0x0c>
a::#un:
#undef <0x0c>
a::/*-:
/*
* $end$
*/<0x0c>
a:::
//
<0x0c>
a:API注释:*A:
/**@brief $end$
*
*
*
* @param[]
* @param[]
*
* @return
*/<0x0c>
a:do { ... } while ():do:
do {
$selected$
} while ($end$);
<0x0c>
a:do while(0)宏定义:do0:
do { \
$end$ \
}while(0)<0x0c>
a::fl:
float<0x0c>
a:for () { ... }:for:
for ($end$) {
}
<0x0c>
a:for loop reverse:forr:
for (int i = 0; i < $end$ ; i++) {
}
<0x0c>
a:if () { ... }:if:
if ($end$) {
}
<0x0c>
a:if () { ... } else { }:ife:
if ($end$) {
}
else {
}
<0x0c>
a::ll:
long long<0x0c>
a::N=:
NULL == <0x0c>
a::sti:
static inline <0x0c>
a::switch:
switch ($end$) {
case :
break;
}
<0x0c>
a::tps:
typedef struct {
}$end$;
<0x0c>
a:u8:u8:
uint8_t<0x0c>
a::u16:
uint16_t<0x0c>
a::u32:
uint32_t<0x0c>
a::ui:
unsigned int<0x0c>
a::ul:
unsigned long<0x0c>
a:while () { ... }:while:
while ($end$) {
$selected$
}
<0x0c>
a:头文件:#id:
#ifndef __$FILE_BASE_UPPER$_H__
#define __$FILE_BASE_UPPER$_H__
$selected$
#endif
<0x0c>
readme:
VA Snippet used for suggestions of type bool.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:SuggestionsForType bool::
true
false
<0x0c>
readme:
VA Snippet used for suggestions in class definitions.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:SuggestionsForType class::
public:
private:
protected:
virtual
void
bool
string
static
const
<0x0c>
readme:
VA Snippet used for suggestions of type HANDLE.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:SuggestionsForType HANDLE::
INVALID_HANDLE_VALUE
NULL
<0x0c>
readme:
VA Snippet used for suggestions in loops.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:SuggestionsForType loop::
continue;
break;
<0x0c>
readme:
VA Snippet used for suggestions in switch statements.
If you have modified this item, you may delete it to restore the default upon next use.
<0x0c>
a:SuggestionsForType switch::
case
default:
break;
<0x0c>