在linux下vim中使tags高亮

來源:互聯網
上載者:User


在linux下vim中使tags高亮 高亮標籤 *tag-highlight*    www.2cto.com   如果你想高亮檔案裡的所有標籤,可以使用如下映射。 <F11> -- 產生 tags.vim 檔案,並高亮標籤。
  <F12> -- 只根據已有的 tags.vim 檔案高亮標籤。 :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12> :map <F12> :so tags.vim<CR>  警 告: 標籤檔案越長,這會越慢,而 Vim 消耗的記憶體也越多。  這裡只高亮 typedef,也可以針對 union 和 struct 進行設定。為此,你需要 Exuberant ctags (可在 http://ctags.sf.net 找到)。  在你的 Makefile 裡放入以下的行:  # 建立 types 的高亮檔案。需要 Exuberant ctags 和 awk types: types.vim types.vim: *.[ch]      ctags -i=gstuS -o- *.[ch] |\        awk 'BEGIN{printf("syntax keyword Type\t")}\                  {printf("%s ", $$1)}END{print ""}' > $@ 在你的 .vimrc 裡放入以下的行: " 載入 types.vim 高亮檔案,如果存在的話 autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim' autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname autocmd BufRead,BufNewFile *.[ch] endif ==================================================以上的F11隻能識別函數內部的定義,函數名等,不能識別宏定義。自己改成"根據tags檔案產生高亮檔案tags.vimmap <F11> :sp tags<CR>:set nohls<CR>:%s/file/fi le/<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>"高亮檔案裡的所有標籤map <F12> :so tags.vim<CR>就可以識別宏了 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.