You are not logged in.

#1 2010-10-19 07:43:13

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

autocmd commands are not applied from ~/.vimrc

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

#2 2010-10-19 08:20:09

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: autocmd commands are not applied from ~/.vimrc

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

#3 2010-10-19 08:42:45

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

Re: autocmd commands are not applied from ~/.vimrc

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

#4 2010-10-19 15:44:10

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: autocmd commands are not applied from ~/.vimrc

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

#5 2010-10-19 19:15:18

jolly_roger
Member
Registered: 2010-10-13
Posts: 6

Re: autocmd commands are not applied from ~/.vimrc

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

#6 2011-02-18 15:50:36

hughitt1
Member
Registered: 2010-02-18
Posts: 82
Website

Re: autocmd commands are not applied from ~/.vimrc

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?)

Offline

Board footer

Powered by FluxBB