配置VIM下面的Python环境

This item was filled under [ vim, 一步一步学习中 ]

原文:http://hi.baidu.com/camark/blog/item/0806cc3f37a390c67d1e71ae.html]http://hi.baidu.com/camark/blog/item/0806cc3f37a390c67d1e71ae.html(有改动)
不知道为什么,我的vi安装了vim-python以后依然没有语法加亮和自动缩进功能,使用起来非常的不顺手。今天下定决心,自己Google一下,终于搞定。
完成以后有一下功能:
1、Python语法加亮
2、自动缩进
3、自动补全
4、自动完成
哈哈,用起来是否顺手。
在这里记录一下,配置过程。
1、安装软件包,最好安装vim-full包和vim-python
sudo aptitude install vim-full vim-python
2、建立自己的.vimrc 文件,我的配置如下(参考自ubuntu中文论坛)
” 自动补全命令时候使用菜单式匹配列表
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 代码
” 来自http://vim.sourceforge.net/scripts/script.php?script_id=850
autocmd FileType python set complete+=k~/.vim/tools/pydiction-1.2
自动补全需要下载pydiction这个软件包,可以从这里下载:

http://vim.sourceforge.net/scripts/script.php?script_id=850

解压文件
tar xzvf pydiction-1.2.tar.gz
得到一个文件夹pydiction-1.2文件夹。
拷贝文件夹里面的pydiction文件到Home目录下面的.vim/tools目录下面(如果没有,需要手工建立):
mkdir -p ~/.vim/tools
然后启动vim,就会看到vim自动进入Python模式了,包括语法加亮和自动缩进功能。
按F8或者Ctrl+N会出现“自动完成的提示”。

还是非常舒服啊!
对于vim,我还是一个初学者,自己加油啊!

Bookmark and Share
Tagged with: [ , , , ]

喜欢这篇文章的人还喜欢。。。

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment