vim插件之 cvim 牛b啊

vim插件之 cvim 和 cscope
来源:  ChinaUnix博客  日期:2009.04.01 23:14 (共有条评论)  我要评论
 

               
[/url]
Step 1: 下载c.vim
$ cd /usr/src
$ wget http://www.vim.org/scripts/download_script.php?src_id=9679
Step 2: 安装
$ mkdir ~/.vim
$ cd ~/.vim
$ unzip /usr/src/cvim.zip
Step 3: 启用这一插件
$ vim ~/.vimrc
filetype plugin on
8 c.vim的使用
Feature 1: Add Automatic Header to *.c file
当你新建一个扩展名.c的文件时候,自动在文件头部增加头部注释
$ vim myprogram.c
其中如果你要改变 AUTHOR 和
COMPANY的值, 要修改模板文件
~/.vim/c-support/templates/Templates
$ vim ~/.vim/c-support/templates/Templates
|AUTHOR|    = geekstuff
|AUTHORREF| = gk
|EMAIL|     = subscribe@geekstuff
|COMPANY|   = thegeekstuff.com
现在编辑一个新文件,看看你的作者和公司名称改变了没有。
$ vim myprogram.c

Feature 2: 用\if 添加c函数
键入\if 加函数名称 (as shown in Fig1
below) 就会在文件中自动完成函数的定义,就像图二那样。



Fig1:Insert C Function Automatically


Fig 2:Insert C Function Automatically
Feature 3: 用\im 添加main函数
添加的效果如下:


Fig 3: Insert C main function automatically
Feature 4: 用 \cfu 添加函数注释



Fig 4: Insert C Function Header Automatically


Fig 5: Insert C Function Header Automatically
Feature 5:  用\cfr添加注释框架



Fig 6: Insert a Frame Comment Automatically
Feature 6: 用\p
Type \p”, and places
the cursor in the
Feature 7: 保存编译文件.
保存并编译文件 \rc.
运行 \rr.
Feature 8: 用\nr 插入预定义的代码片段
The plugin comes with few pre-defined code snippets that you can
insert into your code. Following are the default code snippets that
comes with the plugin.
$ ls ~/.vim/c-support/codesnippets
Makefile                        calloc_double_matrix.c  main.c   print_double_array.c.noindent
Makefile.multi-target.template  calloc_int_matrix.c     main.cc  print_int_array.c.noindent
For example, if you want to create a function that will Allocate
a dynamic int-matrix of size rows*columns; return a pointer, you
can re-use it from the existing code snippets. Following is the
content of the calloc_int_matrix.c pre-defined code snippets.
int**
calloc_int_matrix ( int rows, int columns )
{
int   i;
int **m;
m     = calloc ( rows, sizeof(int*) );       
assert( m != NULL );                         
*m    = calloc ( rows*columns, sizeof(int) );
assert(*m != NULL );                         
for ( i=1; i
m  = m[i-1] + columns;
return m;

如果要插入这段代码,可以键入\nr 文件名称,代码就会自动插入了。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值