vim插件使用 c.vim

 

vim插件使用(一) -- c.vim


http://vitaminj.blogbus.com/logs/35851648.html

尽管假期的时候浏览了一遍vimtutor,但使用vim敲代码时还是不是很得心应手,一方面由于vim normal模式下快捷键颇多,一时半会还是难以完全的灵活掌握,另一方面发现我的vim插件少的可怜,需要好好打造一下。

c.vim的功能就不介绍了,直接来这里可以看到并且提供下载地址。

安装方法也很简单,

直接解压到~/.vim/(for linux)或者/vimfiles/(for win),并且plugin on一下就可以了,具体可以看插件附带的readme.

这里提供使用方法,我做一下简单的总结。

----------华丽分割------------

1.在~/.vim/c-support/templates/Templates可以设置版权信息,如作者、信箱、版权归属等,新建.c或.cpp文件是可以看到,并且列出了使用模板文件位置,可以自己编辑

2./if    插入一般函数

3./im    插入主函数

4./cfu    插入函数头,即函数说明

5./cfr    插入一个frame comment,可以用来写变量说明

6./p<    插入一个include , 并且把光标放在<>中

7./rc    保存并编译

8./rr   运行

9./nr    可以在~/.vim/c-support/codesnippets中编写一些预编译代码或者代码块,通过此命令使用

---------------------------------------------

总之c.vim是个不错的c/c++辅助代码插件 , 恩.

---------------------附:详细的c.vim hotkey-------------------------

-- Help ---------------------------------------------------------------



  /hm       show manual for word under the cursor (n,i)

  /hp       show plugin help                      (n,i)



  -- Comments -----------------------------------------------------------



  /cl       end-of-line comment                 (n,v,i)

  /cj       adjust end-of-line comment(s)       (n,v,i)

  /cs       set end-of-line comment column      (n)

  /c*
*
 */               (n,v)

  /cc       code -> comment //                  (n,v)

  /co       comment -> code                     (n,v)

  /cfr      frame comment                       (n,i)

  /cfu      function comment                    (n,i)

  /cme      method description                  (n,i)

  /ccl      class description                   (n,i)

  /cd       date                                (n,v,i)

  /ct       date /& time                        (n,v,i)



  -- Statements ---------------------------------------------------------



  /sd       do { }
 while                        (n,v,i)

  /sf       for                                 (n,i)

  /sfo      for { }
                             (n,v,i)

  /si       if                                  (n,i)

  /sif      if { }
                              (n,v,i)

  /sie      if else                             (n,v,i)

  /sife     if { }
 else { }
                     (n,v,i)

  /sw       while                               (n,i)

  /swh      while { }
                           (n,v,i)

  /ss       switch                              (n,v,i)

  /sc       case                                (n,i)

  /s{       { }
                                 (n,v,i)



  -- Preprocessor -------------------------------------------------------



  /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)



  -- Idioms -------------------------------------------------------------



  /if       function                            (n,v,i)

  /isf      static function                     (n,v,i)

  /im       main()                              (n,v,i)

  /i0       for( x=0; x<n; x+=1 )               (n,v,i)

  /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)

  /ii       open input file                     (n,i)

  /io       open output file                    (n,i)



  -- Snippets -----------------------------------------------------------



  /nr       read code snippet                   (n,i)

  /nw       write code snippet                  (n,v,i)

  /ne       edit code snippet                   (n,i)

  /np       pick up prototype                   (n,v,i)

  /ni       insert prototype(s)                 (n,i)

  /nc       clear  prototype(s)                 (n,i)

  /ns       show   prototype(s)                 (n,i)

  /ntl      edit local templates                (n,i)

  /ntg      edit global templates               (n,i)

  /ntr      rebuild templates                   (n,i)



  -- C++ ----------------------------------------------------------------



  /+co      cout  <<  << endl;                  (n,i)

  /+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)



  -- Run ----------------------------------------------------------------



  /rc       save and compile                    (n,i)

  /rl       link                                (n,i)

  /rr       run                                 (n,i)

  /ra       set comand line arguments           (n,i)

  /rm       run make                            (n,i)

  /rg       cmd. line arg. for make             (n,i)

  /rp       run splint                          (n,i)

  /ri       cmd. line arg. for splint           (n,i)

  /rk       run CodeCheck (TM)                  (n,i)

  /re       cmd. line arg. for CodeCheck (TM)   (n,i)

  /rd       run indent                          (n,v,i)

  /rh       hardcopy buffer                     (n,v,i)

  /rs       show plugin settings                (n,i)

  /rx       set xterm size                      (n, only Linux/UNIX & GUI)

  /ro       change output destination           (n,i)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vim使用Coc.nvim插件可以提供强大的自动补全、语法检查和代码导航等功能。下面是如何在vim使用Coc.nvim进行自定义的步骤: 1. 安装Coc.nvim插件:首先需要安装Coc.nvim插件,可以通过插件管理器(如Vundle、Pathogen、vim-plug等)进行安装。 2. 配置Coc.nvim:在vim的配置文件(一般是~/.vimrc或~/.config/nvim/init.vim)中添加以下配置: ``` " 启用Coc.nvim插件 let g:coc_enable = 1 " 配置Coc.nvim的扩展列表 let g:coc_global_extensions = [ \ 'coc-python', \ 'coc-clangd', \ 'coc-tsserver', \ ] " 配置Coc.nvim的键位绑定 nmap <silent> <leader>jd :call CocAction('jumpDefinition')<CR> nmap <silent> <leader>rn :call CocAction('rename')<CR> ``` 这里的配置示例中启用了Coc.nvim插件,并配置了一些常用的扩展(如coc-python、coc-clangd、coc-tsserver),还定义了一些快捷键绑定(如<leader>jd用于跳转到定义,<leader>rn用于重命名)。 3. 安装和配置Coc.nvim扩展:根据需要安装和配置相应的Coc.nvim扩展。例如,如果你需要在C语言项目中使用Coc.nvim的自动补全和语法检查功能,可以安装并配置coc-clangd扩展。 ``` :CocInstall coc-clangd ``` 安装完成后,可以在vim使用`:CocConfig`命令打开Coc.nvim的配置文件,对扩展进行更详细的配置。 4. 自定义Coc.nvim的设置:可以通过`:CocConfig`命令打开Coc.nvim的配置文件,对Coc.nvim的行为进行自定义设置。例如,可以配置自动补全的触发方式、忽略某些文件类型等。 ``` { "suggest.autoTrigger": "always", "suggest.ignoreBuffer": true } ``` 这里的配置示例中设置了自动补全的触发方式为始终触发,并忽略当前缓冲区的文件。 以上是在vim使用Coc.nvim进行自定义的基本步骤。你可以根据自己的需求进一步探索Coc.nvim插件的功能和配置。希望对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值