用c.vim插件打造C/C++集成编辑器
来源:互联网 发布:mysql mac安装教程 编辑:程序博客网 时间:2024/06/09 17:35
- 添加文件头
- 添加注释
- 插入一些代码片段
- 语法检查
- 读函数文档
- 注释代码块
这一插件的作者是 Fritz Mehner, 目标就是打造程序员流畅的编辑环境。
这一插件还能完成:
- Statement oriented editing of C / C++ programs
- Speed up writing new code considerably.
- Write code and comments with a professional appearance from the beginning.
- Use code snippets
接下来我们对这一插件详细介绍.
3 安装插件
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 ~/.vimrcfiletype plugin on
8 c.vim的使用
Feature 1: Add Automatic Header to *.c file
当你新建一个扩展名.c的文件时候,自动在文件头部增加头部注释
$ vim myprogram.c/** =================================================* Filename: myprogram.c** Description:** Version: 1.0* Created: 01/19/09 20:23:25* Revision: none* Compiler: gcc** Author: Dr. Fritz Mehner (mn), mehner@fh-swf.de* Company: FH Südwestfalen, Iserlohn** =================================================*/
其中如果你要改变 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/** =================================================** Filename: myprogram.c** Description:** Version: 1.0* Created: 01/19/09 20:26:43* Revision: none* Compiler: gcc** Author: geekstuff (gk), subscribe@geekstuff* Company: thegeekstuff.com** =================================================*/
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< in the normal mode, which will include the text “#include <>”, and places the cursor in the < symbol in Insert mode where you can type the header file name.
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/codesnippetsMakefile calloc_double_matrix.c main.c print_double_array.c.noindentMakefile.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.
/** === FUNCTION ======================================================================* Name: calloc_int_matrix* Description: Allocate a dynamic int-matrix of size rows*columns; return a pointer.* =====================================================================================*/int**calloc_int_matrix ( int rows, int columns ){int i;int **m;m = calloc ( rows, sizeof(int*) ); /* allocate pointer array */assert( m != NULL ); /* abort if allocation failed */*m = calloc ( rows*columns, sizeof(int) ); /* allocate data array */assert(*m != NULL ); /* abort if allocation failed */for ( i=1; im[i] = m[i-1] + columns;return m;} /* ———- end of function calloc_int_matrix ———- */
如果要插入这段代码,可以键入"nr 文件名称,代码就会自动插入了。
- 用 c.vim插件打造C/C++集成编辑器
- 用c.vim插件打造C/C++集成编辑器
- 用c.vim插件打造C/C++集成编辑器
- 用c.vim插件打造C/C++集成编辑器
- 用c.vim插件打造C/C++集成编辑器
- 用c.vim插件打造C/C++集成编辑器
- Vim:打造Linux C/C++程序员的编辑器
- Vim:打造Linux C/C++程序员的编辑器
- Vim:打造Linux C/C++程序员的编辑器
- Vim:打造Linux C/C++程序员的编辑器
- Vim:打造Linux C/C++程序员的编辑器
- cygwin+ctags+taglist 打造vim c语言编辑器(IDE)
- Vim:打造Linux C/C++程序员的编辑器
- Vim:打造Linux C/C++程序员的编辑器
- vim 打造 C/C++ IDE
- c.vim插件使用方法
- vim下插件c.vim
- vim插件使用 c.vim
- main 带参数 简单说明
- Content Provider 基础
- Objective C 模板方法模式
- TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议
- MyEclipse优化
- 用c.vim插件打造C/C++集成编辑器
- JNI与JNA性能比较
- TCP/IP详解学习笔记(4)-ICMP协议,ping和Traceroute
- LINQ TO XML C#实例 类和XML文件互转换
- const指针的了解
- ADADMIN - Generate Applications Files 菜单项详解
- UBUNTU安装PHP mysql
- SSH配置之web.xml .
- TCP/IP详解学习笔记(5)-IP选路,动态选路,和一些细节