casio1374633

导航

 

晚上好好看了下这个c.vim.然后尝试创建更加适合自己的命令:

首先.在*/.vim/c-support/templates/Templates文件中加入

|includefile| = c.需要添加的文件名.template

例如我现在用到freescale单片机.就写了

|includefile| = c.freescale.template



注意在c.vim里面 $起头表示注释


======================================================================

再在你自己创建的文件里面(我这里创建的是c.freescale.template文件).就可以依葫芦花瓢来添加了,比如我添加的如下:

$
$--------------------------start of comment here --------------------------------
$
$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
== comment.MCU_FUNCTION ==
/*
* === Freescale_MCU ======================================================================
* Name: |?FUNCTION_NAME|
* Description: <CURSOR>
* Cross Time :
* =====================================================================================
*/
$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
== comment.MCU_BIT_DESCRIPT ==
/* ||||||||
 * |||||||+---<CURSOR>
 * ||||||+----<++> $<<注意我这里选用了<++> 这样在编辑的时候可以使用Ctrl_j进行跳转,十分方便,下同.
 * |||||+-----<++>
 * ||||+------<++>
 * |||+-------<++>
 * ||+--------<++>
 * |+---------<++>
 * +----------<++>
 *
 *Description:<++>
 */
<++>
$
$---------------------------start of function here ------------------------------
$
$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
== function.MCU_INTERRUPT_FUNCTION ==
void interrupt <CURSOR> |?FUNCTION_NAME|( <++> )
{
<SPLIT><++>
}
<++>
$
$-----------------------start of preprocessor here ------------------------------
$
$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
== preprocessor.
#pragma CODE_SEG __NEAR_SEG NON_BANKED
<++>
#pragma CODE_SEG DEFAULT
$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

=====================================================================

最后在 */.vim/ftplugin/c.vim文件里面最后添加如下,这样整个就关联起来了:

(后面我不再标明,直接使用freescale,看官若想尝试,自己对应修改)

"
"-------------------------------------------------------------------------------
"freescale MCU mapping
"-------------------------------------------------------------------------------
"
inoremap <buffer> <silent> <LocalLeader>fcf <Esc>:call C_InsertTemplate("comment.MCU_FUNCTION")<CR>
inoremap <buffer> <silent> <LocalLeader>fcb <Esc>:call C_InsertTemplate("comment.MCU_BIT_DESCRIPT")<CR>
inoremap <buffer> <silent> <LocalLeader>ffi <Esc>:call C_InsertTemplate("function.MCU_INTERRUPT_FUNCTION")<CR>

=======================================================================
做完上面三部以后就可以找个foo.c尝试下了,肯定很happy!!

=======================================================================

如果添加的太多,容易忘记,那么就要添加进用户手册里面:

在*/.vim/doc/csupport.txt这个文件内首先找到这个位置:

=======================================================================
2. USAGE WITHOUT GUI (Vim) *csupport-usage-vim*
=======================================================================

然后在下面这样添加:

-- Freescale MCU ------------------------------------------------------

\fcf (C)omment the function
\fcb (C)omment the binary setting
\ffi creat (F)unction for (I)nterrupt
\fpn creat (P)reprocessor

======================================================================

这样就彻底的大功告成了!

posted on 2013-04-29 20:52  casio1374633  阅读(256)  评论(0编辑  收藏  举报