macro GetFileName(pathName)
{
nlength = strlen(pathName)
i = nlength - 1
extlen =0
name = ""
while (i >= 0 )
{
ch = pathName[i]
if (ch == ".")
break
else
i = i - 1
}
start = nlength - 1
while (start >= 0 )
{
ch = pathName[start]
if (ch == "\\")
break
else
start = start - 1
}
//Msg (i )
//没有后缀
if(i<0)
{
return pathName
}
namelen = start+1
while ( namelen < i )
{
name = cat(name, pathName[namelen])
namelen = namelen + 1
}
return name
}
macro GetFileExtName(pathName)
{
nlength = strlen(pathName)
i = nlength - 1
extlen =0
name = ""
namelen=0
while (i >= 0 )
{
ch = pathName[i]
if (ch == ".")
break
else
i = i - 1
}
//没有后缀
if(i<0)
{
return name
}
namelen = i + 1
while ( namelen < nlength )
{
name = cat(name, pathName[namelen])
namelen = namelen + 1
}
return name
}
macro SwitchCppFile()
{
//hbufnew=hNil
hbuf = GetCurrentBuf()
bufname = GetBufName (hbuf)
file_len=strlen(bufname)
new_file_name=""
file_name = GetFileName(bufname)
//MSG(file_name)
file_ext = GetFileExtName(bufname)
if(file_ext =="h")
{
new_file_name = cat(file_name,".cpp")
hbufnew = OpenBuf(new_file_name)
if(hbufnew == hNil)
{
new_file_name = cat(file_name,".c")
if(hbufnew == hNil)
{
error_msg= cat("error file ",bufname)
MSG(error_msg)
return
}
}
SetCurrentBuf(hbufnew)
}
else
{
if( file_ext == "cpp" )
{
new_file_name = cat(file_name,".h")
hbufnew = OpenBuf(new_file_name)
if(hbufnew == hNil)
{
error_msg= cat("error file ",bufname)
MSG(error_msg)
return
}
SetCurrentBuf(hbufnew)
}
else
{
if( file_ext == "c" )
{
new_file_name = cat(file_name,".h")
hbufnew = OpenBuf(new_file_name)
if(hbufnew == hNil)
{
error_msg= cat("error file ",bufname)
MSG(error_msg)
return
}
SetCurrentBuf(hbufnew)
}
else
{
error_msg= cat("error file ",bufname)
msg(error_msg)
return
}
}
}
}
macro InsertHeaderDefine()
{
hbufCur = GetCurrentBuf()
lnCur = GetBufLnCur(hbufCur)
bufName = GetBufName(hbufCur)
fileName = GetFileName(bufName)
upperName = toupper(fileName)
upperName = cat("_", upperName)
upperName = cat(upperName, "_H_" )
InsBufLine(hbufCur, lnCur, "#ifndef @upperName@ ")
lnCur = lnCur+1
InsBufLine(hbufCur, lnCur, "#define @upperName@ ")
lnCur = lnCur+2
InsBufLine(hbufCur, lnCur, "#endif ")
}
1. 打开所在目录
创建一个Custom Command: ShellExecute open %d. 然后关联一个快捷键。
同理, 创建Custom Command: ShellExecute open "http://www.google.com/search?q=%w" 可以实现用Google搜索选中的词。
打开资源管理器并选中当前文件
ShellExecute open explorer /e,/select,%f
2. 获取扩展名: