zoukankan      html  css  js  c++  java
  • gVIM+ctags+Taglist+winmanager搭建IDE

    对于一个初级程序员,Vim和Emacs始终是一个很难跨越的栏,在11年的时候,接触Linux,从而也自然的学习Vim,但是那时候真就是不习惯,Windows的习惯始终无法改过来,随着毕业就不了了之。。。

    今年,有从事了单片机开发的工作,至少碰上code了,于是乎想在Vim上动动脑经,学习一下,也参考网上的资料,终于搞了一天,弄出来了,于是就记录一下,是个好习惯,不是吗?

    首先,所有的安装包都可以从vim官网下载,安装gvim,我的安装路径是d盘的program files(后来想想还是直接放在d盘好~~),这个时候的vim自带的功能已经很强大了,但是做一个大项目还是有限吃力,所以才会有IDE的出现,方便我们的开发。我这里也是很粗略的,其实还有很大的空间可以提升!~

    Ctags是什么?官网的解释是:

    Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).

    Taglist呢??

    The "Tag List" plugin is a source code browser for the Vim editor. It provides an overview of the structure of source code files and allows you to efficiently browse through source code files in different programming languages. It is the top-rated and most-downloaded plugin for the Vim editor.

    The taglist plugin groups and displays the functions, classes, structures, enumerations, macro definitions and other parts of a source code file in a Vim window. The taglist plugin will automatically highlight the current tag. You can jump to the definition of a tag by selecting the tag name from the taglist window. For a list of features supported by the taglist plugin, visit the features page.

    他俩的结合就能碰触火花~~哈哈!我之前一直在cfree下编辑代码,然后在别的编译器里编译,给个cfree的截图:

     

    左边的就是函数(宏定义等)列表,点击一个就会使光标制指定到程序相应的位置去,方便我们查找函数的位置,上面两个就是实现这个功能的。

    Taglist文件的压缩包里都有doc和plugin两个文件,对应vim安装目录下的doc和plugin,看出点什么了吧,分别把两个文件里的文件copy到vim安装目录下,这样就安装好了,简单吧~;对于ctags,我起初解压在d盘的program files文件里,结果怎么地都不成功,后来我考虑到program files有个空格,于是我干脆把ctags解压在d盘下,并添加在系统变量里,这才是我的函数列表出来了,狂喜!对于winmanager插件,安装很简单,和taglist一样。接下去的事情就是在编译_vimrc文件。

    第二,我把自己的_vimrc的内容显示如下:

      1 set nocompatible
      2 source $VIMRUNTIME/vimrc_example.vim
      3 source $VIMRUNTIME/mswin.vim
      4 behave mswin
      5 syntax enable
      6 syntax on 
      7 set guifont=Courier\ New:h13
      8 set nu!
      9 set ts=4
     10 set sw=4
     11 set smartindent
     12 set laststatus=2
     13 set cursorline
     14 set autoindent
     15 set cindent
     16 set linebreak
     17 set hidden
     18 set gdefault
     19 set scrolloff=5
     20 set ruler        " 在编辑过程中,在右下角显示光标位置的状态行
     21 set hlsearch    " 高亮显示搜索结果
     22 set incsearch    " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到
     23 set ignorecase smartcase
     24 set foldmethod=syntax
     25 set foldlevel=100       " Don't autofold anything (but I can still fold manually)
     26 filetype pluginindenton       " 加了这句才可以用智能补全
     27 set showmatch       " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
     28 set noexpandtab
     29 set tabstop=4
     30 set nobk
     31 
     32 
     33 "--------------------------------------------------------------------------------
     34 " 代码折叠
     35 "--------------------------------------------------------------------------------
     36 set foldmarker={,}
     37 "set foldmethod=marker
     38 set foldmethod=syntax
     39 set foldlevel=100       " Don't autofold anything (but I can still fold manually)
     40 "set foldopen-=search   " don't open folds when you search into them
     41 "set foldopen-=undo     " don't open folds when you undo stuff
     42 "set foldcolumn=4
     43 
     44 
     45 "Taglist------------------------------------------------
     46 "==================================================
     47 let Tlist_Show_Menu=1
     48 let Tlist_Ctags_Cmd='D:\ctags58\ctags.exe'”这句话可有可无,但我还是加了,以防万一
     49 let Tlist_Auto_Open=1
     50 let Tlist_File_Fold_Auto_Close=0
     51 let Tlist_Compact_Format=1
     52 let Tlist_Enable_Fold_Column=1
     53 let Tlist_Sort_Type="order"
     54 set tags=tags;
     55 set autochdir         " 自动设置目录为正在编辑的文件所在的目录
     56 
     57 filetype plugin on
     58 
     59 " taglist configuration vimrc file.
     60 "
     61 " Maintainer:     Bruce Ouyang <bruce.oy@gmail.com>
     62 "
     63 let Tlist_Display_Prototype = 1
     64 let Tlist_Sort_Type = "order"           "使taglist以tag名字进行排序
     65 let Tlist_Show_One_File = 1            "不同时显示多个文件的tag,只显示当前文件的
     66 let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口,则退出vim
     67 let Tlist_Use_Right_Window = 0         "在右侧窗口中显示taglist窗口
     68 let Tlist_Use_SingleClick = 1          "单击tag就跳转到定义
     69 let Tlist_GainFocus_On_ToggleOpen = 1  "使用:TlistToggle打开taglist窗口时,输入焦点在taglist窗口中
     70 nmap <silent> <F9> :TlistToggle<CR>    "打开tag窗口,这个是设置快捷键
     71 
     72 """"""""""""""
     73 ""winmanager
     74 """"""""""""""
     75 let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'
     76 "nmap <silent> <F10> :WMToggle<cr>
     77 nmap wm :WMToggle<cr> " 是nomal模式的命令,不是Ex模式的,这个是设置快捷键
     78 
     79 
     80 """"""""""""""""""""""""""""""""""""""""""""""
     81 ""omni completion 
     82 """"""""""""""""""""""""""""""""""""""""""""""
     83 set nocp
     84 set ofu=syntaxcomplete#Complete
     85 
     86 set diffexpr=MyDiff()
     87 function MyDiff()
     88   let opt = '-a --binary '
     89   if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
     90   if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
     91   let arg1 = v:fname_in
     92   if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
     93   let arg2 = v:fname_new
     94   if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
     95   let arg3 = v:fname_out
     96   if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
     97   let eq = ''
     98   if $VIMRUNTIME =~ ' '
     99     if &sh =~ '\<cmd'
    100       let cmd = '""' . $VIMRUNTIME . '\diff"'
    101       let eq = '"'
    102     else
    103       let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    104     endif
    105   else
    106     let cmd = $VIMRUNTIME . '\diff'
    107   endif
    108   silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
    109 endfunction

    效果图:

     按下wm,如下:

    哈哈!I get it!~

  • 相关阅读:
    networkX用法整
    在人生路上对我影响最大的三位老师
    介绍自己
    介绍自己
    自我介绍
    打印沙漏1
    介绍自己
    对我影响最大的三位老师
    人生路上影响对我最大的三位老师
    1.自我介绍
  • 原文地址:https://www.cnblogs.com/CodeWorkerLiMing/p/2829330.html
Copyright © 2011-2022 走看看