用vim新建一个python文件后,如pw.py,会自动填写文件头部,如:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # Pw @ 2013-04-15 17:26:33
将以下代码加入/etc/vim/vimrc文件:
function HeaderPython() call setline(1, "#!/usr/bin/env python") call append(1, "# -*- coding: utf-8 -*-") call append(2, "# Pw @ " . strftime(‘%Y-%m-%d %T‘, localtime())) normal G normal o normal o endf autocmd bufnewfile *.py call HeaderPython()
时间: 2024-11-12 17:52:09