Payton Chou 2008/11/18 How to trace code like source insight through vim?
Vim hierarchy <ul><li>/etc/vim </li></ul><ul><li>|-- colors  # theme </li></ul><ul><li>|   `-- ir_black.vim </li></ul><ul>...
How to equip vim <ul><li>Install it </li></ul><ul><ul><li>apt-get install vim vim-gnome exuberant-ctags cscope </li></ul><...
Basic setting of vim <ul><li>set showmatch        &quot; Show matching brackets. </li></ul><ul><li>set ignorecase        &...
The killer of trace code tools <ul><li>Trinity (trinity.vim) </li></ul><ul><ul><li>NERD_tree.vim  </li></ul></ul><ul><ul><...
Advance setting of vim – font, theme, key mapping <ul><li>Font </li></ul><ul><ul><li>set gfn=Consolas 12 </li></ul></ul><u...
Advance setting of vim - devhelp <ul><li>&quot; vim macro to jump to devhelp topics. </li></ul><ul><li>&quot; ------------...
Advance setting of vim – Search on line <ul><li>&quot; online doc search </li></ul><ul><li>&quot; ------------------------...
Demo trace code through vim <ul><li>Supertab </li></ul><ul><li>Trinity </li></ul><ul><li>Online help </li></ul><ul><li>dev...
Reference (1/3) <ul><li>My vim package </li></ul><ul><ul><li>http://vip-file.com/download/8dd841907924/vim.tar.bz2.html </...
Reference (2/3) <ul><li>VIM Reference Card </li></ul><ul><ul><li>http://www.linux.ie/articles/tutorials/vim-3.0.refcard.ht...
Reference (3/3) <ul><li>最后强烈推荐水木社区 bbs 的 vim 版面 :  http://bbs.newsmth.net ,那里面高手如云,是国内最好的有关 vim 的专业版面。 </li></ul><ul><li>h...
<ul><li>Thanks for your kind attention </li></ul>EeePC SWRD Chi-Heng Chou
Upcoming SlideShare
Loading in …5
×

[20081118] How To Trace Code Like Source Insight Through Vim

8,123 views
7,841 views

Published on

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,123
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
122
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

[20081118] How To Trace Code Like Source Insight Through Vim

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

×