macvim打造python IDE

昨天安装了macvim,今天在上面配置了一下python的ide:

大家也可参考http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/

1.文法高亮

  为了能在Vim中支持Python文法需要用到插件python.vim,该插件默认位于<Vim安装目录>/<$VIMRUNTIME>/syntax/下,如果你在该路径下没有找到这个插件,需要到python.vim : Enhanced version of the python syntax highlighting script下载。然后为了能让Vim识别Python文法需要在vimrc中添加:


set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf python


2.缩进

  在vimrc中添加如下缩进相关的代码:

set autoindent " same level indent
set smartindent " next level indent
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4

3. taglist
能够列出源文件中的tag(function, class, variable, etc)并跳转.
注意:taglist依赖于ctags,所以要先装ctags,否则taglist装了也没法用!
(1)到 http://vim.sourceforge.net/scripts/script.php?script_id=273
下载taglist_42.zip,即
http://vim.sourceforge.net/scripts/download_script.php?src_id=6416
(2)解压得到两个文件
# unzip -d taglist taglist_42.zip
# cd taglist
# tree
.
|-- doc
| `-- taglist.txt 
`-- plugin
`-- taglist.vim
(3)安装
cp doc/taglist.txt /usr/share/vim/vim61/doc/
cp plugin/taglist.vim /usr/share/vim/vim61/plugin/
(4)配置和使用
cd /usr/share/vim/vim61/doc/
启动vim,用 “:helptags .”来配置好帮助文件
重启vim,用“:TlistToggle”来打开和关闭taglist窗口。
可以用“:help taglist”来获得更多帮助信息


4.MiniBufExplorer

  在Visual Studio或Eclipse中你打开的缓存会以tab的形式列在窗口的顶端或底部,在Vim中插件MiniBufExplorer来实现此功能。下载minibufexpl.vim并将其放在plugin目录下。接着在vimrc中添加如下命令:

let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1

下图展示了MiniBufExplorer的使用效果:

5.Omnicompletion

  Vim7中添加了对文法提示和自动完成的支持,对于python来说需下载pythoncomplete.vim并将其放在<Vim安装目录>/<$VIMRUNTIME>/autoload/目录下,接着在vimrc中添加如下命令:

filetype plugin on
set ofu=syntaxcomplete#Complete
autocmd FileType python set
omnifunc=pythoncomplete#Complete
autocmd FileType python runtime! autoload/pythoncomplete.vim

  最后在编写代码时通过ctrl-x ctrl-o来打开文法提示上下文菜单,如下图所示:





转载于:https://www.cnblogs.com/lixingle/p/3707709.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值