学无止境

——把简单的知识用好,也把东西做的简单

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

最近工作环境换到了Windows环境下,但是还是不习惯使用其它的编辑器,继续使用vim,其中还有到其它的一些插件,可能你无法直接使用,仅供参考学习。

下面是我的Windows下的_vimrc设置:

set nocompatible
set tags=./tags,tags
"set tags=./tags,tags,E:/Projects/php/tags

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

autocmd GUIEnter * simalt ~x

set guioptions=EgrLt
map <silent> <M-m> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
"set bin noendofline
set nu ai nobackup guifont=consolas:h11
set autochdir
"lcd %:p:h
set autoindent smartindent
:hi normal guibg=black guifg=white

set fileencoding=utf-8
set fileencodings=GB232,utf-8,gbk,ucs-bom,GB8030,default,latin

if has(
"multi_byte")
"set encoding=utf-8
endif

set expandtab
set tabstop=4 softtabstop=4 shiftwidth=4
set mouse=a selection=exclusive selectmode=mouse,key

if has('gui_running')
let do_syntax_sel_menu
=1
endif

if bufname('')==''
cd $HOME
endif

autocmd FileType php
set dictionary+=D:\ShellAlias\backup\php.list
autocmd FileType javascript
set dictionary+=D:\ShellAlias\backup\js.list
autocmd FileType html
set dictionary+=D:\ShellAlias\backup\js.list
autocmd BufNewFile *
.html 0r E:\Projects\others\vim\html\model.html
imap
<C-u> <C-x><C-k>

map
<F5> :call CompileRunGcc()<CR>
func! CompileRunGcc
()
exec
"w"
exec
"!gcc %"
exec
"!a"
endfunc

map
<F6> :call CompileRunGpp()<CR>
func CompileRunGpp
()
exec
"w"
exec
"!gpp %"
exec
"!a"
endfunc

map
<F7> :call CompileRunJava()<CR>
func CompileRunJava
()
exec
"w"
exec
"!javac %"
exec
"!java %<"
endfunc

map
<F8> :call RunPhp()<CR>
func RunPhp
()
exec
"w"
exec
"!php %"
endfunc

map
<F9> :RunHtml<CR>

map
\at :call AppendTime()<CR>
func AppendTime
(...)
"let format = '%c'
let format = '%Y-%m-%d %H:%M:%S'
let editinfo = ['/*', ' * Last modified time: '.strftime(format,getftime(expand(
"%:p"))), ' * Edit time: '.strftime(format,localtime()), ' * File name: '.expand('%'), ' */']
call append(line('.'),editinfo)
endfunc

map \je :call JSEscape()<CR>
func JSEscape(...)
let JSString = ['<script type=
"text/javascript">','//<![CDATA[','//]]>','</script>']
call append(line('.'),JSString)
call cursor(line(
".")+2,11111111)
return 1
endfunc

map \fs :call FileSet()<CR>
func FileSet(...)
let @z = '/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */'
"exec "pu! z"
exec
":call append(line('.'),@z)"
return 1
endfunc

map
<C-n> :tabnew<CR>
map
<S-Left> :tabp<CR>
map
<S-Right> :tabn<CR>
for a in range(1,9)
exe 'map
<A-' . a . '> ' . a . 'gt'
endfor

map
\tt :TlistToggle<CR>
map
<S-Up> :TlistToggle<CR>
"let Tlist_Ctags_Cmd = 'D:\Projects\shell\ctags.exe'
let Tlist_Use_Right_Window = 1
let Tlist_GainFocus_On_ToggleOpen = 1

map \dsl :g/^[ ]*$/d<CR>
map \dse :%s/[ ]*$//g<CR>
map \t2s :%s/\t/ /g<CR>
map \s2t :%s/ /\t/g<CR>
map \lcd :lcd %:p:h<CR>
"map \cd :cd %:p:h<CR>
map
\ed :Xpr<CR>
map
\df :call Differ()<CR>
func Differ
()
exec
":set diff"
exec
":set scrollbind"
exec
":set guioptions+=b"
endfunc
map
\ndf :call Notdiffer()<CR>
func Notdiffer
()
exec
":set nodiff"
exec
":set noscrollbind"
exec
":set guioptions-=b"
endfunc

map
\cmd :Start<CR>
map
<silent> <S-Down> :Start<CR>

map
\nt :NERDTreeToggle<CR>
map
<S-CR> :NERDTreeToggle<CR>
let NERDTreeIgnore
=['\.exe$','\.gif$','\.png$','\.jpeg$','\.swf$','\.ttc$','^CVS$','^SVN$']

set diffexpr=MyDiff()
function MyDiff
()
let opt
= '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1
= v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2
= v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3
= v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq
= ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let
cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '
"'
else
let
cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let
cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!'
. cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

"Following is html editing settings
if exists(
"b:did_ftplugin")
finish
endif

let b:html_mode = 1
let xml_use_xhtml = 1

if !exists(
"*HtmlAttribCallback")
function HtmlAttribCallback( xml_tag )
if a:xml_tag ==?
"table"
return
"cellpadding=\"0\" cellspacing=\"0\" border=\"0\""
elseif a
:xml_tag ==? "link"
return "href=\"/site.css\" rel=\"StyleSheet\" type=\"text/css\""
elseif a
:xml_tag ==? "body"
return "bgcolor=\"white\""
elseif a
:xml_tag ==? "frame"
return "name=\"NAME\" src=\"/\" scrolling=\"auto\" noresize"
elseif a
:xml_tag ==? "frameset"
return "rows=\"0,*\" cols=\"*,0\" border=\"0\""
elseif a
:xml_tag ==? "img"
return "src=\"\" width=\"0\" height=\"0\" border=\"0\" alt=\"\" /"
elseif a
:xml_tag ==? "input"
return 'type="" value=""'
elseif a
:xml_tag ==? "a"
if has("browse")
" Look up a file to fill the href. Used in local relative file
" links. typeing your own href before closing the tag with `>'
" will override this.
let cwd = getcwd()
let cwd = substitute (cwd,
"\\", "/", "g")
let href = browse (0,
"Link to href...", getcwd(), "")
let href = substitute (href, cwd .
"/", "", "")
let href = substitute (href,
" ", "%20", "g")
else
let href =
""
endif
return
"href=\"" . href . "\""
else
return 0
endif
endfunction
endif

" On to loading xml.vim
runtime ftplugin/xml.vim
本文的原始链接为:http://www.cnblogs.com/jaiho/archive/2011/05/17/2049403.html转载请注明原始链接。
posted on 2011-05-17 22:45  JaiHo  阅读(7653)  评论(0编辑  收藏  举报