You are not logged in.
Hi all,
I have tried to configure vim for editing Python's script, but basic configuration that I found on Python wiki doesn't work from my ~/.vimrc
Here lines that I added to my ~/.vimrc
autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
But simply adding "syntax on" to ~/.vimrc works great.
Thanks.
Offline
The names of the files you're trying it with end with ".py"? Is there anything else in your .vimrc? If so, please pastebin it...
If you're using a custom vim installation, i.e. not from the official repos, is there a "+autocmd" in the output of `vim --version'?
Offline
Yes, I have checked this on files with end ".py". No, I don't have anything else in my ~/.vimrc. Yes, I use vim from repository. Sorry, but now I can't check output of "vim --version", but maybe following will be helpful, yesterday I tried to input command ":autocmd" in vim, and saw a lot of autocmd configuration.
Offline
Okay, I'm home now and tried out your minimalistic .vimrc.
It seems changing it to:
syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
solves the problem. This way vim's syntax highlighting is activated for every file, not only *.py. Using it in the autocmd statement does not work.
If you want syntax highlighting only for python files, you could also add "filetype on" on top of your .vimrc, because it also works.
Offline
Thanks for pointing solution with filetype, now, that I wanted, works great, and my .vimrc contains following configuration
filetype on
autocmd FileType python syntax on
autocmd FileType python set ai
autocmd FileType python set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
Offline
Is anyone using vim-python from the AUR? I am pretty new to vim. I am able to get some simple syntax highlighting by adding:
autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
to my .vimrc file, but it seems to not be as nice as the highlighting in other vim installations I've used (perhaps where support was compiled in?)
Keith
dotfiles
Offline