Chinaunix首页 | 论坛 | 博客
  • 博客访问: 545397
  • 博文数量: 203
  • 博客积分: 245
  • 博客等级: 二等列兵
  • 技术积分: 1288
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-16 10:29
文章分类

全部博文(203)

文章存档

2023年(4)

2022年(21)

2021年(7)

2020年(5)

2019年(1)

2018年(6)

2017年(11)

2016年(15)

2015年(52)

2014年(37)

2013年(26)

2012年(18)

我的朋友

分类: LINUX

2013-06-07 12:48:03

"au VimLeave * mksession! $VIMRUNTIME/Session.vim
"au VimLeave * wviminfo! $VIMRUNTIME/_viminfo
"source $VIMRUNTIME/Session.vim
"rviminfo $VIMRUNTIME/_viminfo

"记录上次关闭的文件及状态
set viminfo='10,\"100,:20,%,n$VIMRUNTIME/_viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

"设置插件SuperTab
"设置按下后默认的补全方式, 默认是,
"现在改为. 关于的补全方式,
"还有其他的补全方式, 可以看看下面的一些帮助:
":help ins-completion
":help compl-omni
let g:SuperTabRetainCompletionType=2
"0 - 不记录上次的补全方式
"1 - 记住上次的补全方式,直到用其他的补全命令改变它
"2 - 记住上次的补全方式,直到按ESC退出插入模式为止
let g:SuperTabDefaultCompletionType=""

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 =~ '\ 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

"phpDocumentor
"this includes the script and maps the combination + p
"to the doc functions.
source $VIM\vimfiles\plugin\php-doc.vim
imap :call PhpDocSingle()i
nmap :call PhpDocSingle()
vmap :call PhpDocRange()

"You can obtain the completion dictionary file from:
"
set dictionary+=$VIM\vimfiles\syntax\function.txt

"Use the dictionary completion
set complete-=k complete+=k

"Alt + -> 打开下一个文件
map :bn
"Alt + <- 打开上一个文件
map :bp

"使用TAB键自动完成
"This function determines, wether we are on
"the start of the line text(then tab indents)
"or if we want to try auto completion
function! InsertTabWrapper()
let col=col('.')-1
if !col || getline('.')[col-1] !~ '\k'
return "\"
else
return "\"
endif
endfunction
"使用SuperTab之后,就可以关闭该设置了
"inoremap =InsertTabWrapper()

"平台判断
function! GetSystem()
if (has("win32") || has("win95") || has("win64") || has("win16"))
return "windows"
elseif has("unix")
return "linux"
elseif has("mac")
return "mac"
endif
endfunction

"取得光标处的匹配
function! GetPatternAtCursor(pat)
let col = col('.') - 1
let line = getline('.')
let ebeg = -1
let cont = match(line, a:pat, 0)
while (ebeg >= 0 || (0 <= cont) && (cont <= col))
let contn = matchend(line, a:pat, cont)
if (cont <= col) && (col < contn)
let ebeg = match(line, a:pat, cont)
let elen = contn - ebeg
break
else
let cont = match(line, a:pat, contn)
endif
endwh
if ebeg >= 0
return strpart(line, ebeg, elen)
else
return ""
endif
endfunction

"打开链接
function! OpenUrl()
let s:url = GetPatternAtCursor('\v(https?://|ftp://|file:/{3}|www\.)((\w|-)+\.)+(\w|-)+(:\d+)?(/(\w|[~@#$%^&+=/.?-])+)?')
"echo s:url
if s:url == ""
echohl WarningMsg
echomsg '在光标处未发现URL!'
echohl None
else
if GetSystem() == "windows"
call system("explorer " . s:url)
else
call system("firefox " . s:url . " &")
endif
endif
unlet s:url
endfunction
nmap :call OpenUrl()

"放大字体
function FontSize_Enlarge()
if GetSystem() == "linux"
let pattern = '\<\d\+$'
elseif GetSystem() == "windows"
let pattern = ':h\zs\d\+\ze:'
endif
let fontsize = matchstr(&gfn, pattern)
let cmd = substitute(&gfn, pattern, string(fontsize + 1), 'g')
let &gfn=cmd
let fontsize = matchstr(&**, pattern)
let cmd = substitute(&**, pattern, string(fontsize + 1), 'g')
let &**=cmd
endfunction
nnoremap :call FontSize_Enlarge()

"缩小字体
function FontSize_Reduce()
if GetSystem() == "linux"
let pattern = '\<\d\+$'
elseif GetSystem() == "windows"
let pattern = ':h\zs\d\+\ze:'
endif
let fontsize = matchstr(&gfn, pattern)
let cmd = substitute(&gfn, pattern, string(fontsize - 1), 'g')
let &gfn=cmd
let fontsize = matchstr(&**, pattern)
let cmd = substitute(&**, pattern, string(fontsize - 1), 'g')
let &**=cmd
endfunction
nnoremap :call FontSize_Reduce()

"html自动输入匹配标签,输入>之后自动完成匹配标签
au FileType xhtml,xml so ~/.vim/ftplugin/html_autoclosetag.vim

"能够漂亮的显示.NFO文件
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()

""""""""""""""""""""""""""""""
" 设置lookupfile插件
""""""""""""""""""""""""""""""
let g:LookupFile_MinPatLength = 2 "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0 "不保存上次查找的字符串
let g:LookupFile_PreservePatternHistory = 1 "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1 "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0 "不允许创建不存在的文件
if filereadable("./filenametags") "设置tag文件的名字
let g:LookupFile_TagExpr = '"./filenametags"'
endif
"映射LookupFile为,lf
nmap ,lf LookupFile
"映射LUBufs为,lb
nmap ,lb :LUBufs
"映射LUWalk为,lw
nmap ,lw :LUWalk
"映射LUPath为,lp
nmap ,lp :LUPath

"F2处理行尾的空格以及文件尾部的多余空行
"Automatically remove trailing spaces when saving a file.
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
"Remove indenting on empty line
map :w:call CleanupBuffer(1):noh
function! CleanupBuffer(keep)
" Skip binary files
if (&bin > 0)
return
endif
" Remove spaces and tabs from end of every line, if possible
silent! %s/\s\+$//ge
" Save current line number
let lnum = line(".")
" number of last line
let lastline = line("$")
let n = lastline
" while loop
while (1)
" content of last line
let line = getline(n)
" remove spac
阅读(1791) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~