cygwin 设置 HOME:
在Cygwin.bat 中的 bash --login -i 前添加
set HOME=XXX\cygwin\home\XXX
cygwin 使用apt : 参考http://code.google.com/p/apt-cyg/
$cd /bin
#下载 cyg-apt 修改权限
$svn exporthttp://apt-cyg.googlecode.com/svn/trunk//bin
$chmod +x /bin/apt-cyg
#名子改短点
$mv apt-cyg apt
#更新
$apt update 或
$apt -mhttp://www.cygwin.cn/pub/update
#然后就可以使用apt了
$apt show
$apt find XXX
$apt install XXX
#1:创建一些目录和文件
$mkdir ~/.vim/{plugin,doc,syntax} -p
$touch ~/.vimrc
#2:安装中文帮助手册,下载地址:http://vimcdoc.sourceforge.net/
$tar xvf vimcdoc-1.7.0.tar.gz
$cd vimcdoc-1.7.0/
$./vimcdoc.sh -i
#3:安装C-support,下载地址:http://www.vim.org/scripts/script.php?script_id=213
$cd ~/.vim
$unzip cvim.zip
#4:安装Ctags + Tag list + WinManager : 用来分析源码中Tags(function, class, variable, etc)
# Ctags 安装 : apt install ctags
# Teh List 下载地址 :http://www.vim.org/scripts/download_script.php?src_id=7701# WinManager(调整窗口布局)下载地址:http://www.vim.org/scripts/script.php?script_id=95
$apt install ctags
$unzip taglist_45.zip
$unzip winmanager.zip
#5:安装supertab+snipMate+echofunc : 超级补全
#supertab :http://www.vim.org/scripts/script.php?script_id=1643
#snipMate :http://www.vim.org/scripts/script.php?script_id=2540
#echofunc :http://www.vim.org/scripts/script.php?script_id=1735
$vim supertab.vba
:so %
$unzip snipMate.zip
$cp echofunc.vim plugin/
#6: 安装 astyle : 代码格式整理
$apt install astyle
#7: 安装NERD_tree : 多tab支持
$unzip NERD_tree.zip
#8:生成系统头文件和STL库的tags
$ctags -R -f ~/.vim/systags --c-kinds=+p --c++-kinds=+px --fields=+iaS --extra=+q /usr/include
$ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ /lib/gcc/i686-pc-cygwin/4.3.4/include
总结一下现在可以使用的快捷键 :
F3 文件浏览器
F4 Tags浏览器
F5 make
2*F5 make clean
F6 quickfix查看详细信息
2*F6 关闭详细信息
F7 下一个结果
2*F7 上一个结果
F8 编译和运行单个程序
2*F8 调试单个程序
F9 编译
Ctrl+F9 执行
Shift+F9 设置命令行参数
F10 在该行后边添加注释
Shift+F10 注释掉该行
2*(Shift+F10) 去掉改行的注释
F11 格式化代码
F12 建立目录及子目录下的索引Tags
Shift+t 新建标签
2*(Shift+t) 标签间跳转
Shift+o 建立新行但是不插入
Ctrl+a 全选
2*(Shift+q) 快速不保存
Ctrl+h 替换
Tags相关:Ctrl+\+字母 :
* s: 查找C语言符号,即查找函数名、宏、枚举值等出现的地方
* g: 查找函数、宏、枚举等定义的位置,类似ctags所提供的功能
* d: 查找本函数调用的函数
* c: 查找调用本函数的函数
* t: 查找指定的字符串
* e: 查找egrep模式,相当于egrep功能,但查找速度快多了
* f: 查找并打开文件,类似vim的find功能
* i: 查找包含本文件的文件
TagList操作:
跳到光标下tag所定义的位置,用鼠标双击此tag功能也一样
o 在一个新打开的窗口中显示光标下 tag 显示光标下tag的原型定义
u 更新taglist窗口中的tag
s 更改排序方式,在按名字排序和按出现顺序排序间切换
x taglist窗口放大和缩小,方便查看较长的tag
+ 打开一个折叠,同zo
- 将tag折叠起来,同zc
* 打开所有的折叠,同zR
= 将所有tag折叠起来,同zM
[[ 跳到前一个文件
]] 跳到后一个文件
q 关闭taglist窗口
显示帮助 : 在浏览代码时Taglist常用操作为:
gd 转到当前光标所指的局部变量的定义
* 转到当前光标所指的单词下一次出现的地方
# 转到当前光标所指的单词上一次出现的地方
ctrl+] 转到函数定义的地方
ctrl+o 回退到函数调用的地方
Winmanager文件操作技巧:
显示帮助
如果光标下是目录, 则进入该目录; 如果光标下文件, 则打开该文件
- 返回上级目录
c 切换vim 当前工作目录正在浏览的目录
d 创建目录
D 删除目录或文件
i 切换显示方式
R 文件或目录重命名
s 选择排序方式
x 定制浏览方式, 使用你指定的程序打开该文件
C-Support常见补全结构与快捷键
-- 常用结构 ---------------------------------------------------------
\sd do { } while
\sf for
\sfo for { }
\sif if { }
\sife if { } else { }
\swh while { } (n,v,i)
\ss switch (n,v,i)
\sc case (n,i)
\s{ { } (n,v,i)
-- 预处理命令 -------------------------------------------------------
\p< #include <> (n,i)
\p" #include "" (n,i)
\pd #define (n,i)
\pu #undef (n,i)
\pie #if #else #endif (n,v,i)
\pid #ifdef #else #endif (n,v,i)
\pin #ifndef #else #endif (n,v,i)
\pind #ifndef #def #endif (n,v,i)
\pi0 #if 0 #endif (n,v,i)
\pr0 remove #if 0 #endif (n,i)
\pe #error (n,i)
\pl #line (n,i)
\pp #pragma (n,i)
-- 常用短语 -------------------------------------------------------------
\im main() (n,v,i)
\i0 for( x=0; x
\in for( x=n-1; x>=0; x-=1 ) (n,v,i)
\ie enum + typedef (n,i)
\is struct + typedef (n,i)
\iu union + typedef (n,i)
\ip printf() (n,i)
\isc scanf() (n,i)
\ica p=calloc() (n,i)
\ima p=malloc() (n,i)
\isi sizeof() (n,v,i)
\ias assert() (n,v)
-- C++ ----------------------------------------------------------------
\+c class (n,i)
\+cn class (using new) (n,i)
\+ci class implementation (n,i)
\+cni class (using new) implementation (n,i)
\+mi method implementation (n,i)
\+ai accessor implementation (n,i)
\+tc template class (n,i)
\+tcn template class (using new) (n,i)
\+tci template class implementation (n,i)
\+tcni template class (using new) impl. (n,i)
\+tmi template method implementation (n,i)
\+tai template accessor implementation (n,i)
\+tf template function (n,i)
\+ec error class (n,i)
\+tr try ... catch (n,v,i)
\+ca catch (n,v,i)
\+c. catch(...) (n,v,i)
Code Complete常用结构:Ctrl +b补全
xt 插入当前时间
C/C++语言:
cc /* */
de #define
in #include ""
is #include <>
ff #ifndef
ife if...els
BASH:
sif if
sife if...els
scase case
swhile while
suntil until
sfor for
sselect select