LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tune vi for python (https://www.linuxquestions.org/questions/linux-newbie-8/tune-vi-for-python-653100/)

dongli 07-02-2008 10:37 AM

tune vi for python
 
Hi, everyone

I want to tune vim to be convenient for editing python code. The vim has already turned on filetype and related plugins, so I create a file "python.vim" in "~/.vim/ftplugin", and add the following lines in it:

Code:

" tune indentation
setlocal shiftwidth=4
setlocal smarttab
setlocal smartindent
setlocal cinwords=if,elif,else,for,while,try,except,finally,def,class
setlocal autoindent

" template
0read ~/.vim/template/python.template | normal G

The first block is fine, but I met a trouble with the second one. The purpose I write it is to automatically use a specific template for a new python code file, but the result is that it is executed everytime a python code file is opened, no matter it is new or old. That is not what I want.

I know I can set it in "~/.vimrc" by

Code:

...
autocmd BufNewFile *.py 0read ~/.vim/template/python.template | normal G
...

But it is a little loose, and it doesn't use vim specific filetype. So how does vim know a python code file is new or old in python.vim above.

Thanks for help!

Mr. C. 07-03-2008 03:02 AM

Try asking on the vim.org forums; you might be more likely to get fast response there.


All times are GMT -5. The time now is 04:59 PM.