工欲善其事,必先利其器。软件开发更是如此,linux上的软件开发更是如此。
我的linux开发工具是:source insight(si)编辑器+indent代码格式工具+vmware5.0 + linux smb服务器 + gcc + gdb.
编辑器source insight是个很好的选择,毕竟linux vi是在文本界面上的咚咚。利用si强大的功能,加上indent代码格式化工具,很好的解决了代码编辑和格式问题。如何把编辑好的代码进行编译?利用ftp是一个选择,但其实利用smb协议,进行windows和linux文件夹共享,则可实现“所见即所得”效果的文件修改-〉保存-〉编译。
vmware虚拟机需要安装vmware toos,在vmware界面中-〉vm-〉install vmware tools;安装完后,在vmware界面中-〉setting-〉options-〉share folders进行共享文件夹的选择。
进入linux ,设置网络,启动smb服务,执行mount //ip/sharefolder mount-point ,输入windows 用户密码,ok!
indent 需要下载indent for windows版本,安装后,需要把它加入source insight环境中,它每次只对当前文件进行格式化。在SourceInsight 的 base project 的路径,创建一个叫 indent.em 的 Source Insight 宏定义文件:[code] macro indent()
{
execIndent = "F:\\Program Files\\GnuWin32\\bin\\indent.exe";
//sPara = " -kr ";
sPara = "-ut --tab-size4 -bl -nce -bls -bli0 --line-length120 -kr ";
hbuf = GetCurrentBuf();
sFile = GetBufName (hbuf);
if (checkExtension(sFile))
{
SaveBuf(hbuf); // save Buffer first ,then open a cmd execute windows with minimized state [2] .
//msg("CmdLine = \"@execIndent@\" @sPara@ \"@sFile@\" ");
//msg("CmdLine = \"@execIndent@\" @sPara@ \"@sFile@\" -o \"@sFile@\" ");
exitcode = ShellExecute("open", "\"@execIndent@\"", "@sPara@ \"@sFile@\" -o \"@sFile@\" ", "", 2);
// PS: Do not REMOVE the following statement that seem no use , or will cause "Reload Problem".
exitcode = RunCmdLine("cmd /c echo \"Reflushing ...\"; cmd /c exit",".",true);
RunCmd("Reload File");
RunCmd("Reload Modified Files");
RunCmd("Parse File Now");
}
}
macro CheckExtension(sFile)
{
nLength = strlen(sFile)
while (nLength > 0)
{
if (sFile[nLength] == ".")
break
nLength = nLength - 1
}
ext = strmid(sFile, nLength+1, strlen(sFile))
if ( ext == "c"
|| ext == "cpp"
|| ext == "h"
|| ext == "hpp")
return True
else
return False
}[/code]然后打开 SouceInsight 默认的 Base Project,倒入该文件到工程中-〉rebuild;然后在si中-〉options-〉key assignments-〉macro:indent,输入命令,如indent-〉insert;
在si上可见work->indent,注意indent直接修改文件,适合在编译通过后点击indent进行缩进。注意在si中的
tab的宽度可以由上面的--tab-size指定,但传入linux后,tab格式对应宽度由linux环境的替换,可在linux环境中设置(如set tabstop=4)。


gaochang 于 2008-02-17 00:06:07发表:
liunx 下的source insight 能用吗?