Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101982368
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-05 22:42:16

 
对于上一篇Blog的内容进行了增强,新增功能如下:
1、对于Python关键字的增强:
譬如输入$p,自动替换为print
2、对于代码片段的支持(需要一个改动的imaps.vim文件,保持到~/.vim/plugin即可):
cfun按Tab得到def语句
cclass得到class语句
cclassinit得到class的init语句
cclassmethod得到class的method
cfor得到for语句
还有cif、cifelse等你功能
3、Python直接运行功能,按F7直接运行
具体内容如下:
" 自动补全命令时候使用菜单式匹配列表
set wildmenu
" 允许退格键删除
set backspace=2
" 启用鼠标
set mouse=a
" 文件类型
filetype on
filetype plugin on
filetype indent on
" 设置编码自动识别, 中文引号显示
"set fileencodings=utf-8,cp936,big5,euc-jp,euc-kr,latin1,ucs-bom
set fileencodings=utf-8,gbk
set ambiwidth=double

" 移动长行
nnoremap gj
nnoremap gk

" 高亮
syntax on
" 设置高亮搜索
set hlsearch
" 输入字符串就显示匹配点
set incsearch
" 输入的命令显示出来,看的清楚些。
set showcmd

" 打开当前目录文件列表
map :e .

" Taglist
let Tlist_File_Fold_Auto_Close=1
set updatetime=1000
map :Tlist

" 按 F8 智能补全
inoremap

" vim 自动补全 Python 代码
" 来自
autocmd FileType python set complete+=k~/.vim/tools/pydiction
" 自动使用新文件模板
autocmd BufNewFile *.py 0r ~/.vim/template/simple.py

"自动关键字补全,譬如输入$p,自动变换为print;输入$c,自动添加注释行
au FileType python inoremap $r return
au FileType python inoremap $s self
au FileType python inoremap $i import
au FileType python inoremap $p print
au FileType python inoremap $c ####kla
au FileType python inoremap $d """"""0


"设置Python运行
autocmd FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
autocmd FileType python set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m

"设置Python 代码片段,使用Ctrl+J在模板参数之间跳转
autocmd FileType python inorea cfun =IMAP_PutTextWithMovement("def <++>(<++>):\n<++>\nreturn <++>")
autocmd FileType python inorea cclass =IMAP_PutTextWithMovement("class <++>:\n<++>")
autocmd FileType python inorea cfor =IMAP_PutTextWithMovement("for <++> in <++>:\n<++>")
autocmd FileType python inorea cif =IMAP_PutTextWithMovement("if <++>:\n<++>")
autocmd FileType python inorea cifelse =IMAP_PutTextWithMovement("if <++>:\n<++>\nelse:\n<++>")
autocmd FileType python inorea cclassinit =IMAP_PutTextWithMovement("def __init__(self,<++>):\n<++>")
autocmd FileType python inorea cclassmethod =IMAP_PutTextWithMovement("def <++>(self,<++>):\n<++>")

function! Python_Eval_VSplit() range
    "let src=tempname()
    let dst=tempname()
    "execute ": " . a:firstline . ",". a:lastline . ' w '.srca
    let filename=bufname("%")
    execute ":!python " . filename . " > " . dst
    execute ":pedit! " . dst
endfunction

"按F7自动运行buffer里面的内容
au FileType python map :call Python_Eval_VSplit()

imap
"Format the statusline
"Nice statusbar
set laststatus=2
set statusline=
set statusline+=%2*%-3.3n%0*\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%1*%m%r%w%0* " flag
set statusline+=[
if v:version >= 600
set statusline+=%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
endif
set statusline+=%{&fileformat}] " file format
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
set statusline+=\ %{VimBuddy()} " vim buddy
endif
set statusline+=%= " right align
"set statusline+=%2*0x%-8B\ " current char
set statusline+=0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset


现在看来vim的扩展功能确实好啊!
新的配置文件下载:
阅读(380) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~