[應用軟體
]
14 三月, 2007 21:32
平常習慣用vim寫程式,有人問我為何要用這麼難用的編輯器? 怎不用ultraedit,其實理由很簡單,哪個環境我都可以寫東西! 就是這麼簡單。
在這邊紀錄一些 vim tips,希望對vim users有幫助。
環境相關設定
"指定term
set term=xterm-color
"指定:sh跑非$SHELL變數的shell
set shell=/usr/local/bin/bash
CSS格式
set term=xterm-color
"指定:sh跑非$SHELL變數的shell
set shell=/usr/local/bin/bash
CSS格式
讓.css檔案可以在vim直接呈現所設定的顏色
http://tokyoenvious.xrea.jp/b/vim/immediate_css_color.html

http://tokyoenvious.xrea.jp/b/vim/immediate_css_color.html

支援4gl格式
內建支援.4gl highlight ,下列提供自動排版(indent)及.per highlight 功能
download 4gl indent from
fgl.vim : Indent script for IBM INFORMIX 4GL/4Js programs
download 4gl indent from
fgl.vim : Indent script for IBM INFORMIX 4GL/4Js programs
into C:vimvimfilesindent
支援.per
download per.vim from
http://www.lacorona.com.mx/fortiz/vim/syntax/per.vim
into C:vimvim70syntax
vi filetype.vim
" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
au BufNewFile,BufRead *.per setf per
自動將keyword轉大寫
download sql專用的 , 改成fgl版
http://www.vim.org/scripts/script.php?script_id=305
放置
vimfilesftpluginfgl or /usr/local/share/vim/vim70/ftplugin (rename成 fgl.vim)
加上一些keyword
"4gl spec
inoreabbr <silent> <buffer> if <C-R>=SqlIab_ReplaceConditionally('if', 'IF')<CR>
inoreabbr <silent> <buffer> else <C-R>=SqlIab_ReplaceConditionally('else', 'ELSE')<CR>
inoreabbr <silent> <buffer> call <C-R>=SqlIab_ReplaceConditionally('call', 'CALL')<CR>
inoreabbr <silent> <buffer> let <C-R>=SqlIab_ReplaceConditionally('let', 'LET')<CR>
inoreabbr <silent> <buffer> when <C-R>=SqlIab_ReplaceConditionally('when', 'WHEN')<CR>
inoreabbr <silent> <buffer> end <C-R>=SqlIab_ReplaceConditionally('end', 'END')<CR>
inoreabbr <silent> <buffer> otherwise <C-R>=SqlIab_ReplaceConditionally('otherwise', 'OTHERWISE')<CR>
inoreabbr <silent> <buffer> before <C-R>=SqlIab_ReplaceConditionally('before', 'BEFORE')<CR>
inoreabbr <silent> <buffer> after <C-R>=SqlIab_ReplaceConditionally('after', 'AFTER')<CR>
inoreabbr <silent> <buffer> input <C-R>=SqlIab_ReplaceConditionally('input', 'INPUT')<CR>
inoreabbr <silent> <buffer> case <C-R>=SqlIab_ReplaceConditionally('case', 'CASE')<CR>
inoreabbr <silent> <buffer> construct <C-R>=SqlIab_ReplaceConditionally('construct', 'CONSTRUCT')<CR>
inoreabbr <silent> <buffer> then <C-R>=SqlIab_ReplaceConditionally('then', 'THEN')<CR>
inoreabbr <silent> <buffer> field <C-R>=SqlIab_ReplaceConditionally('field', 'FIELD')<CR>
inoreabbr <silent> <buffer> report <C-R>=SqlIab_ReplaceConditionally('report', 'REPORT')<CR>
inoreabbr <silent> <buffer> function <C-R>=SqlIab_ReplaceConditionally('function', 'FUNCTION')<CR>
inoreabbr <silent> <buffer> globals <C-R>=SqlIab_ReplaceConditionally('globals', 'GLOBALS')<CR>
支援.per
download per.vim from
http://www.lacorona.com.mx/fortiz/vim/syntax/per.vim
into C:vimvim70syntax
vi filetype.vim
" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
au BufNewFile,BufRead *.per setf per
自動將keyword轉大寫
download sql專用的 , 改成fgl版
http://www.vim.org/scripts/script.php?script_id=305
放置
vimfilesftpluginfgl or /usr/local/share/vim/vim70/ftplugin (rename成 fgl.vim)
加上一些keyword
"4gl spec
inoreabbr <silent> <buffer> if <C-R>=SqlIab_ReplaceConditionally('if', 'IF')<CR>
inoreabbr <silent> <buffer> else <C-R>=SqlIab_ReplaceConditionally('else', 'ELSE')<CR>
inoreabbr <silent> <buffer> call <C-R>=SqlIab_ReplaceConditionally('call', 'CALL')<CR>
inoreabbr <silent> <buffer> let <C-R>=SqlIab_ReplaceConditionally('let', 'LET')<CR>
inoreabbr <silent> <buffer> when <C-R>=SqlIab_ReplaceConditionally('when', 'WHEN')<CR>
inoreabbr <silent> <buffer> end <C-R>=SqlIab_ReplaceConditionally('end', 'END')<CR>
inoreabbr <silent> <buffer> otherwise <C-R>=SqlIab_ReplaceConditionally('otherwise', 'OTHERWISE')<CR>
inoreabbr <silent> <buffer> before <C-R>=SqlIab_ReplaceConditionally('before', 'BEFORE')<CR>
inoreabbr <silent> <buffer> after <C-R>=SqlIab_ReplaceConditionally('after', 'AFTER')<CR>
inoreabbr <silent> <buffer> input <C-R>=SqlIab_ReplaceConditionally('input', 'INPUT')<CR>
inoreabbr <silent> <buffer> case <C-R>=SqlIab_ReplaceConditionally('case', 'CASE')<CR>
inoreabbr <silent> <buffer> construct <C-R>=SqlIab_ReplaceConditionally('construct', 'CONSTRUCT')<CR>
inoreabbr <silent> <buffer> then <C-R>=SqlIab_ReplaceConditionally('then', 'THEN')<CR>
inoreabbr <silent> <buffer> field <C-R>=SqlIab_ReplaceConditionally('field', 'FIELD')<CR>
inoreabbr <silent> <buffer> report <C-R>=SqlIab_ReplaceConditionally('report', 'REPORT')<CR>
inoreabbr <silent> <buffer> function <C-R>=SqlIab_ReplaceConditionally('function', 'FUNCTION')<CR>
inoreabbr <silent> <buffer> globals <C-R>=SqlIab_ReplaceConditionally('globals', 'GLOBALS')<CR>
用Tab猜字
讓vim跟shell一樣,可以用tab到處猜字。
1.安裝SearchComplete
http://vim.sourceforge.net/scripts/script.php?script_id=474
2.安裝SuperTab
http://vim.sourceforge.net/scripts/script.php?script_id=1643
vi _vimrc
"tab的字庫查詢
set complete +=i,],.,b,w,t,k,.
"set complete +=k
set dict+=C:Vimvimfilesdictsnp_dict
if filereadable("/usr/share/dict/words")
set dictionary+=/usr/share/dict/words
endif
"ctrl+p 清單顏色
highlight Pmenu term=NONE cterm=NONE ctermfg=7 ctermbg=5 gui=NONE guifg=White guibg=Magenta
highlight PmenuSel term=NONE cterm=NONE ctermfg=0 ctermbg=7 gui=NONE guifg=Black guibg=White
highlight PmenuSbar term=NONE cterm=NONE ctermfg=7 ctermbg=0 gui=NONE guifg=White guibg=Black
highlight PmenuThumb term=NONE cterm=NONE ctermfg=0 ctermbg=7 gui=NONE guifg=Black guibg=White
1.安裝SearchComplete
http://vim.sourceforge.net/scripts/script.php?script_id=474
2.安裝SuperTab
http://vim.sourceforge.net/scripts/script.php?script_id=1643
vi _vimrc
"tab的字庫查詢
set complete +=i,],.,b,w,t,k,.
"set complete +=k
set dict+=C:Vimvimfilesdictsnp_dict
if filereadable("/usr/share/dict/words")
set dictionary+=/usr/share/dict/words
endif
"ctrl+p 清單顏色
highlight Pmenu term=NONE cterm=NONE ctermfg=7 ctermbg=5 gui=NONE guifg=White guibg=Magenta
highlight PmenuSel term=NONE cterm=NONE ctermfg=0 ctermbg=7 gui=NONE guifg=Black guibg=White
highlight PmenuSbar term=NONE cterm=NONE ctermfg=7 ctermbg=0 gui=NONE guifg=White guibg=Black
highlight PmenuThumb term=NONE cterm=NONE ctermfg=0 ctermbg=7 gui=NONE guifg=Black guibg=White
分頁(Tab)
修改分頁(Tab)顏色
"hi StatusLine guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=lightblue
"hi TabLineFill guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=lightblue
hi TabLine guifg=#90fff0 guibg=#2050d0 ctermfg=black ctermbg=white
hi TabLineSel guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=LightMagenta
"hi StatusLine guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=lightblue
"hi TabLineFill guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=lightblue
hi TabLine guifg=#90fff0 guibg=#2050d0 ctermfg=black ctermbg=white
hi TabLineSel guifg=#90fff0 guibg=#2050d0 ctermfg=white ctermbg=LightMagenta
修改分頁(Tab)快速鍵
將分頁快速鍵改成習慣的ctrl+t 開啟新的分頁(mozilla XD) 、ctrl+w 關閉分頁,ctrl+ 左右鍵 控制前後的tab
vi .vimrc
"vim tab快速鍵
map :tabnext
map :tabprevious
"terminal 下,上面要改成下面,這裡的^[ 是insert mode中 v
"map ^[[D :tabprev
"map ^[[C :tabnext
nmap :tabnew
imap :tabnew
nmap :tabclose
"設定vim -p 檔案上限
set tabpagemax=1000
vi .vimrc
"vim tab快速鍵
map :tabnext
map :tabprevious
"terminal 下,上面要改成下面,這裡的^[ 是insert mode中 v
"map ^[[D :tabprev
"map ^[[C :tabnext
nmap :tabnew
imap :tabnew
nmap :tabclose
"設定vim -p 檔案上限
set tabpagemax=1000
使用滑鼠
"設定使用滑鼠
set mouse=a
set ttymouse=xterm
set ttymouse=xterm
"切換滑鼠模式快速鍵
map m :set mouse=a<CR>
map <Leader>m :set mouse=<CR> "<Leader>就是""
map <Leader>m :set mouse=<CR> "<Leader>就是""
Windows右鍵編輯檔案到Gvim分頁




