Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-02-2008, 11:37 AM   #1
LQ Newbie
Registered: Feb 2008
Posts: 8

Rep: Reputation: 0
Smile 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:

" 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

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!
Old 07-03-2008, 04:02 AM   #2
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Try asking on the forums; you might be more likely to get fast response there.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tune-up required? siesa SUSE / openSUSE 2 10-20-2006 01:27 AM
How to fine tune POSTGRESQL selva_pondy Linux - Software 1 05-20-2006 05:20 PM
howto tune TV-out pingvina Linux - Software 1 02-03-2006 10:34 PM
How to tune 4.1 sound Nad0xFF Linux - Hardware 2 04-10-2005 11:45 AM
Fine Tune Performance Help? Sabeer Linux - General 1 06-03-2003 09:49 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration