vim 工具
vim是一個很好用的工具,小巧精乾的代碼編輯器,怪不得很多人奉為"編輯器之神".IDE寫代碼,除了代碼調試功能外,其它的功能vim都可以實現,並且vim不會佔很多記憶體,所以,寫代碼使用vim完全“夠用”。
下面整理了一下網上關於用vim+ scala開發代碼環境的配置
1 ctags 安裝
下載ctags-X.X.tar
./configure && make
make install (需要使用root使用者)
配置scala 的ctags設定檔,vim ~/.ctags,檔案內容見(https://github.com/derekwyatt/vim-scala/blob/master/ctags/scala.ctags)
2 vim 軟體安裝
依次下載安裝TagList, Cscope ,NERDTREE, SRCEXPL, TRINITY
在TagList 中添加scala支援
vim ~/.vim/plugin/taglist.vim
547 " yacc language
548 let s:tlist_def_yacc_settings = 'yacc;l:label'
549
++ 550 let s:tlist_def_scala_settings ='scala;t:trait;c:class;T:type;' .
++ 551 \'m:method;C:constant;l:local;p:package;o:object'
552 "------------------- end of language specific options--------------------
3 vimrc 設定檔, 以下是我的.vimrc檔案
call pathogen#infect()
call pathogen#helptags()
set nocompatible
syntax on
filetype plugin on
filetype indent on
set autoindent
set softtabstop=2
set tabstop=2
set shiftwidth=2
set ai!
set showmatch
set guioptions-=T
set ruler
set nu
set paste
colorscheme desert
set hlsearch
set backup
set backupext=.shadow
set backupdir=/tmp/vim/
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
" TAGLIST
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
" CSCOPE
set cscopequickfix=s-,c-,d-,i-,t-,e-
" NERDTREE
"map <F2> :NERDTreeToggle<CR>
map <F3> :NERDTreeFind<CR>
let NERDTreeChDirMode=2 "選中root即設定為目前的目錄
let NERDTreeQuitOnOpen=1 "開啟檔案時關閉樹
let NERDTreeShowBookmarks=1 "顯示書籤
let NERDTreeMinimalUI=1 "不顯示協助面板
let NERDTreeDirArrows=1 "目錄箭頭1 顯示箭頭 0傳統+-|號
map <C-A> :!ctags -h ".scala" -R .<CR>
" SRCEXPL
" // The switch of the Source Explorer
"nmap <F7> :SrcExplToggle<CR>
" // Set the height of Source Explorer window
let g:SrcExpl_winHeight = 8
" // Set 100 ms for refreshing the Source Explorer
let g:SrcExpl_refreshTime = 100
" // Set "Enter" key to jump into the exactdefinition context
let g:SrcExpl_jumpKey = "<ENTER>"
" // Set "Space" key for back from the definitioncontext
let g:SrcExpl_gobackKey = "<SPACE>"
" // In order to avoid conflicts, the Source Explorer shouldknow what plugins
" // except itself are using buffers. And you need add theirbuffer names into
" // below listaccording to the command ":buffers!"
let g:SrcExpl_pluginList = [
\ "__Tag_List__",
\ "_NERD_tree_"
\ ]
" // Enable/Disable the local definition searching, and notethat this is not
" // guaranteed to work, the Source Explorer doesn't checkthe syntax for now.
" // It only searches for a match with the keyword accordingto command 'gd'
let g:SrcExpl_searchLocalDef = 1
" // Do not let the Source Explorer update the tags file whenopening
let g:SrcExpl_isUpdateTags = 0
" // Use 'Exuberant Ctags' with '--sort=foldcase -R .' or '-Lcscope.files' to
" // create/update the tags file
let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R ."
" // Set "<F12>" key for updating the tagsfile artificially
let g:SrcExpl_updateTagsKey = "<F12>"
" // Set "<F4>" key for displaying theprevious definition in the jump list
let g:SrcExpl_prevDefKey = "<F4>"
" // Set "<F5>" key for displaying the nextdefinition in the jump list
let g:SrcExpl_nextDefKey = "<F5>"
" TRINITY
" Open and close all the three plugins on the same time
nmap <F8> :TrinityToggleAll<CR>
" Open and close the srcexpl.vim separately
nmap <F9> :TrinityToggleSourceExplorer<CR>
" Open and close the taglist.vim separately
nmap <F10> :TrinityToggleTagList<CR>
" Open and close the NERD_tree.vim separately
nmap <F11> :TrinityToggleNERDTree<CR>
4 效果圖