vim版本:vim72
编写_vimrc或.vimrc文件,不存在就新建一个,在当前用户目录下新建一个
"引用vimrc_example.vim文件, source 是否有点像c++ include 的功能 ,建议在开始处source文件,防止出现在_vimrc中设置的环境
"被source的文件给改变了,
source $VIMRUNTIME/vimrc_example.vim
"取消兼容模式,目前只知道不取消兼容模式会影响撤消的功能,
"设置编码
let &termencoding=&encoding
"chinese是别名,在windows简体中文版应该是cp936,Linux系统应该是zh_CN.utf-8
"chinese是别名,在windows简体中文版应该是cp936,Linux系统应该是zh_CN.utf-8
set fileencodinge=utf-8,chinese
set encoding=utf-8
"设置英文显示字体为Courier_New,中文显示字体为SimHei. h9表示高度为9
"只设置一种字体时: set guifont=Courier_New:h9
set gfn=Courier_New:h9 gfw=SimHei:h9
" 常用设置
" 插入模式(同时应用于Normal模式)下保存并退出,map有点类似快捷键
imap <F12> <ESC> :wq<CR>
map <F12> <ESC> :wq<CR>
" 只保存,不退出。
imap <F11> <ESC> :w<CR>
map <F11> <ESC> :w<CR>
" 在底部显示标尺,显示行号列号和百分比
set ru
" 显示行号
set nu
"设置打开进入插入模式
"set im
" 鼠标点击边缘上下7行时自动滚动
set so=5
" 设置后退键的作用:
"indent:vim默认只删除3个,此选项可继续删除。
"eol:在行首时,继续删除上一行换行符,即合并行。
"start:可直接删除行首的缩进。
set backspace=indent,eol,start
" 设置帮助文件为中文,前提是已经装过了中文帮助文件
set helplang=cn
" 设置显示字体和大小。gfw为等宽汉字字体。
"set gfn=Courier_New:h9 gfw=新宋体:h9
set gfn=Consolas:h9 gfw=新宋体:h9
" 键入时隐藏鼠标
set mousehide
" 配色方案
"colorscheme oceandeep
set whichwrap=h,b,l,s,<,>,[,] "自动折行
set sm
syntax on
" 行标记,所在行/列高亮
"set cursorline
"set cursorcolumn
" 设置tab缩进4格
set sts=4
set expandtab tabstop=4 shiftwidth=4
" 搜索未输入完成即开始进行匹配显示
set is
" 选择文本时光标所在文字也被选中
set selection=inclusive
" 搜索结果高亮显示
set hlsearch is
" 窗口启动自动最大化
"autocmd GUIEnter * simalt ~x
" 隐藏菜单栏
"set guioptions-=m
"set guioptions-=T
"set guioptions-=l
"set guioptions-=L
"set guioptions-=r
"set guioptions-=R
" 大小写不区分,在搜索的时候。
set ignorecase
" tab自动区分补全和缩进
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '/k'
return "/<tab>"
else
return "/<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 备用设置项
"
"set lbr "单词折行
"set wildmode=list:full
"set wildmenu
"set shiftwidth=4
" 不使用selectmode
"set selectmode=
" 不折行
"set nowrap
" 水平/垂直滚动条
"set guioptions+=b
set guioptions+=r
" 不展开tab为空格
"set noet
" 语法折叠
"set foldmethod=syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 其他设置
"
" 加入ctags,Tlist
let Tlist_Ctags_Cmd = 'd:/Progra~1/vim/vim71/ctags56/ctags.exe'
let Tlist_Auto_Open = 0
let Tlist_Exit_OnlyWindow = 0
let tlist_actionscriptt_settings = 'actionscriptt;c:class;f:method;p:property;v:variable'
let Tlist_Use_Right_Window = 1
"let Tlist_Use_SingleClick = 1 "单击跳转
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 状态栏显示
"
set laststatus=2
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
" 状态栏格式定义
set statusline=
set statusline+=%f "path to the file in the buffer, relative to current directory
set statusline+=/ %h%1*%m%r%w%0* " flag
set statusline+=/ [%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=/ CWD:%r%{CurDir()}%h
set statusline+=/ Line:%l/%L
set statusline+=/ [MyBlog:/ http:////www.Liuhuadong.com]
set statusline+=/ %{FileTime()}
fu! FileTime()
let ext=tolower(expand("%:e"))
let fname=tolower(expand('%<'))
let filename=fname . '.' . ext
let msg=""
let msg=msg." ".strftime("(Modified %b,%d %y %H:%M:%S)",getftime(filename))
return msg
endf
fu! CurTime()
let ftime=""
let ftime=ftime." ".strftime("%b,%d %y %H:%M:%S")
return ftime
endf
" 取消自动备份和交换区
set nobackup
set nowb
set noswapfile
set noar
" 粘贴后自动取消插入模式(我们每次粘贴后一般都需要esc退出模式)
ino <C-v> <esc>:set paste<cr>mua<C-R>+<esc>mv'uV'v=:set nopaste<cr>
"imap <C-o> :set paste<cr>:exe PhpDoc()<cr>:set nopaste<cr>i
" 使得注释换行时自动加上前导的空格和星号
set formatoptions=tcqro
" map映射
map <F9> :colorscheme ps_color<cr>
map <F10> :colorscheme oceandeep<cr>
" netrw setting
let g:netrw_winsize = 30
nmap <silent> <leader>fe :Sexplore!<cr>
" 让文本文件也有高亮
augroup filetypedetect
au BufNewFile,BufRead *.* setf ztxt
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" lookupfile 插件参数设置
let g:LookupFile_MinPatLength = 1 "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串
let g:LookupFile_PreservePatternHistory = 1 "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件
if filereadable("./tags") "设置tag文件的名字
let g:LookupFile_TagExpr = '"./tags"'
endif
" 各种语言调试工具PHP、Ruby、Python调试
" PHP <F6>
"function! PhpParseExecute()
" setlocal makeprg=d:/xampp/php/php.exe
" setlocal shellpipe=>
" setlocal errorformat=%m/ in/ %f/ on/ line/ %l
" make %
" clist
"endfunction
"map <F6> :call PhpParseExecute()<CR>
"imap <F6> <ESC>:call PhpParseExecute()<CR>
" 自动完成括号
iab <? <?php<cr><cr>?><up><tab>
iab <a <a href=""></a><esc><left><left><left><left><left>i
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "/<Right>"
else
return a:char
endif
endf
ia xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"source $VIMRUNTIME/fanfou.vim
"所有未知文件类型,当做vim文件处理(可以选择其它文件类型,主要是因为编辑.txt和没有扩展名的时没有语法加亮,所以在此偷懒
if has("autocmd")
autocmd BufEnter,BufRead,BufNewFile,BufFilePost,BufLeave * if &ft == '' || &ft == 'vim' | setf vim | endif
endif