Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2004-09-21 00:21:07
Size: 1285
Editor: xyb
Comment:
Revision 4 as of 2004-09-21 00:32:33
Size: 1696
Editor: xyb
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
''本文档介绍如何在 Vim 中更方便的编写 Python 程序。'' ''本文档介绍如何在 Vim 中更方便的编写 Python 程序。
Line 11: Line 11:
== .vimrc == 作者:Xie Yanbo,版权:创作共用/cc 1.0''

== vimrc ==
Line 13: Line 15:

下面是我的 .vimrc 中与 Python 相关的设置,你可以直接把它们拷贝到你的 vimrc 文件中使用。
Line 37: Line 41:

你可以下载我使用的[attachment:xyb.vimrc 完整的 .vimrc 文件],还有前面配置中用到的模板文件:[attachment:skeleton.py skeleton.py]、[attachment:test.py test.py] 和 [attachment:alltests.py alltests.py]。

在 Vim 中编写 Python 程序

-- xyb [DateTime(2004-09-21T00:21:07Z)] TableOfContents

在 Vim 中编写 Python 程序

本文档介绍如何在 Vim 中更方便的编写 Python 程序。

作者:Xie Yanbo,版权:创作共用/cc 1.0

vimrc

.vimrc 是 Vim 的用户配置文件,我们的大多数定制都得在这个文件中设置。在 Windows 中,它的文件名为 _vimrc。

下面是我的 .vimrc 中与 Python 相关的设置,你可以直接把它们拷贝到你的 vimrc 文件中使用。

if has("autocmd")

  " 自动检测文件类型并加载相应的设置
  filetype plugin indent on

  " Python 文件的一般设置,比如不要 tab 等
  autocmd FileType python setlocal et | setlocal sta | setlocal sw=4

  " Python Unittest 的一些设置
  " 可以让我们在编写 Python 代码及 unittest 测试时不需要离开 vim
  " 键入 :make 或者点击 gvim 工具条上的 make 按钮就自动执行测试用例
  autocmd FileType python compiler pyunit | setlocal makeprg=python\ %
  autocmd FileType python setlocal makeprg=python\ ./alltests.py
  autocmd BufNewFile,BufRead test*.py setlocal makeprg=python\ %

  " 自动使用新文件模板
  autocmd BufNewFile test*.py 0r ~/.vim/skeleton/test.py
  autocmd BufNewFile alltests.py 0r ~/.vim/skeleton/alltests.py
  autocmd BufNewFile *.py 0r ~/.vim/skeleton/skeleton.py

endif

你可以下载我使用的[attachment:xyb.vimrc 完整的 .vimrc 文件],还有前面配置中用到的模板文件:[attachment:skeleton.py skeleton.py]、[attachment:test.py test.py] 和 [attachment:alltests.py alltests.py]。

VimPython (last edited 2009-12-25 07:19:09 by localhost)