2. Vim hierarchy /etc/vim |-- colors # theme | `-- ir_black.vim |-- doc # related intro . | |-- SuperTabContinue.txt | `-- Trinity.txt |-- gvimrc # configure for gvim (vim-gnome) |-- oldvimrc |-- plugin # vim plugin | |-- NERD_tree.vim | |-- cscope_maps.vim | |-- srcexpl.vim | |-- supertab.vim | |-- taglist.vim | `-- trinity.vim |-- vimrc # configure for vim `-- vimrc.tiny # configure for vi EeePC SWRD Chi-Heng Chou
3. How to equip vim Install it apt-get install vim vim-gnome exuberant-ctags cscope Modify your vimrc The vimrc also effect the configure of gvim Go to official site and put the vim plugin in /etc/vim/plugin Enjoy vimming EeePC SWRD Chi-Heng Chou
4. Basic setting of vim set showmatch " Show matching brackets. set ignorecase " Do case insensitive matching set incsearch " Incremental search set mouse=a " Enable mouse usage (all modes) in terminals syntax on set autoindent set tabstop=4 set shiftwidth=4 set expandtab set softtabstop=4 … EeePC SWRD Chi-Heng Chou
5. The killer of trace code tools Trinity (trinity.vim) NERD_tree.vim file browser srcexpl.vim source browser taglist.vim class browser Enhance of ctag cscope_maps.vim symbol search tools Enhance Auto complete supertab.vim EeePC SWRD Chi-Heng Chou
6. Advance setting of vim – font, theme, key mapping Font set gfn=Consolas\ 12 Theme colorscheme ir_black Key mapping Toggle taglist nnoremap <silent> <F12> :TlistToggle<CR> Trinity: Open and close all the three plugins on the same time nmap <F8> :TrinityToggleAll<CR> Trinity: Open and close the srcexpl.vim separately nmap <F9> :TrinityToggleSourceExplorer<CR> Trinity: Open and close the taglist.vim separately nmap <F10> :TrinityToggleTagList<CR> Trinity: Open and close the NERD_tree.vim separately nmap <F11> :TrinityToggleNERDTree<CR> EeePC SWRD Chi-Heng Chou
7. Advance setting of vim - devhelp " vim macro to jump to devhelp topics. " -------------------------------------------- function! DevHelpCurrentWord() let word = expand("<cword>") exe "!devhelp -s " . word redraw! endfunction " Example: bind <ESC>h to start devhelp and search for the word under the " cursor nmap <ESC>h :call DevHelpCurrentWord()<CR> EeePC SWRD Chi-Heng Chou
8. Advance setting of vim – Search on line " online doc search " -------------------------------------------- function! OnlineDoc() let s:browser = "firefox" let s:wordUnderCursor = expand("<cword>") if &ft == "cpp" || &ft == "c" || &ft == "ruby" || &ft == "php" || &ft == "python" let s:url = " http://www.google.com/codesearch?q=".s:wordUnderCursor."+lang:".&ft elseif &ft == "vim" let s:url = " http://www.google.com/codesearch?q=".s:wordUnderCursor else return endif let s:cmd = "silent !" . s:browser . " " . s:url execute s:cmd redraw! endfunction map <ESC>k :call OnlineDoc()<CR> EeePC SWRD Chi-Heng Chou How to use cscope?
9. Demo trace code through vim Supertab Trinity Online help devhelp ctag and cscope ctags * & cscope -R EeePC SWRD Chi-Heng Chou
10. Reference (1/3) My vim package http://vip-file.com/download/8dd841907924/vim.tar.bz2.html vim 的老家 http://vim.sf.net 或者 www.vim.org , 这里有很多 vim 的 tips 和 scripts vim 的中文文档 http://vimcdoc.sourceforge.net/ , 这里有 pdf 格式下载 , 可以下载了慢慢看 . Best of Vim Tips http://www.rayninfo.co.uk/vimtips.html 在你询问某个技巧之前 , 先看看这篇 Best of Vim Tips, 很有可能你就找到答案了 . 作者搜集整理了大量的 vim 技巧 , 15 Years of Vi + 3 years of Vim and still learning , 作者这么说 . 那我们呢 ?vim 的学习是无止境的 , 学的越多 , 你的效率就越高 VIM Quick Reference Card 这个对于新手很有用 , 也许刚开始你记不住那么多 vim 的快捷键 , 没关系 , 打印一张卡片放在手边 , 忘记了可以看看 . http://tnerual.eriogerg.free.fr/vim.html , 这里有 pdf, dvi 和 tex 格式的供下载 vim 新手指南 vimtutor: vim 内置的快速指南 , 强烈建议新手先看看这个交互式的入门教程 执行方法 : vimtutor, 如果是 windows, 在 vim 的安装目录下也有一个 vimtutor.bat 文件 http://www.vi-improved.org/ 这里有给新手的一些建议 , 还有 vimrc 和 gvimrc 的实例 , 稍作修改就可以为己所用 . Vim Cookbook http://www.oualline.com/vim-cook.html EeePC SWRD Chi-Heng Chou
11. Reference (2/3) VIM Reference Card http://www.linux.ie/articles/tutorials/vim-3.0.refcard.html http://www.pinkjuice.com/howto/vimxml/index.xml 如果需要用 vim 编辑 XML, 看看这里的文章 Vim as XML Editor 如果需要用 vim 编辑 LaTex, 看看这里 http://vim-latex.sourceforge.net/ 如果你需要 vim 也能像 source insight 一样的代码自动完成 , 可是试试这个 : Vim Intellisense http://insenvim.sourceforge.net/ 它支持 c++,c#,java,JSP,xml,html 和 SQL 种语言 , 依赖 perl . 缺点是仅仅支持 windows 平台 Vim 的杯子 http://www.cafepress.com/vimrefmug.25635024 你没有看错 , 是 vim 的杯子 ! 上面印着 Vim Reference , 不过一个需要 $10.99, 看清楚 , 是美元 color scheme a) for JAVA http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-java.html b) for HTML http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-html.html c) for PERL http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-pl.html d) for LaTex http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-tex.html EeePC SWRD Chi-Heng Chou
12. Reference (3/3) 最后强烈推荐水木社区 bbs 的 vim 版面 : http://bbs.newsmth.net ,那里面高手如云,是国内最好的有关 vim 的专业版面。 http://yurinfore.blogspot.com/2008/11/vim-google-code-search.html http://blog.roodo.com/thinkingmore/archives/7515251.html http://bhoadmin.blog.sohu.com/99498576.html EeePC SWRD Chi-Heng Chou