Need help with autocmd in vim 7.0 - Editors

This is a discussion on Need help with autocmd in vim 7.0 - Editors ; I have this line in my ~/.vimrc: au BufNewFile *.py | execute "normal i# vim: set ts=4 sw=4 filetype=python:\<CR>\<CR>__date__ = \"$Date: $\"\<CR>__author__ = \"$Author: $\"\<CR>__revision__ = \"$Revision: $\"\<ESC>" The point is so that every time I make a new python ...

+ Reply to Thread
Results 1 to 2 of 2

Need help with autocmd in vim 7.0

  1. Default Need help with autocmd in vim 7.0

    I have this line in my ~/.vimrc:

    au BufNewFile *.py | execute "normal i# vim: set ts=4 sw=4 filetype=python:\<CR>\<CR>__date__ = \"$Date: $\"\<CR>__author__ = \"$Author: $\"\<CR>__revision__ = \"$Revision: $\"\<ESC>"

    The point is so that every time I make a new python script, I start the
    file with a template.

    When I upgraded to vim 7, this config started generating errors. For
    example, when I tried to edit a new file, x.py, I got this error
    message:

    "x.py" [New File]
    Error detected while processing BufNewFile Auto commands for "*.py":
    E749: empty buffer
    Press ENTER or type command to continue

    What am I doing wrong?

    More generally, is there a more appropriate way that I can define
    templates for new files, based on the file name suffix?

    TIA

    Matt


    --
    I'm trying to make money off my blog.
    http://blog.tplus1.com


  2. Default Re: Need help with autocmd in vim 7.0

    Matthew Wilson wrote:
    > I have this line in my ~/.vimrc:
    >
    > au BufNewFile *.py | execute "normal i# vim: set ts=4 sw=4 filetype=python:\<CR>\<CR>__date__ = \"$Date: $\"\<CR>__author__ = \"$Author: $\"\<CR>__revision__ = \"$Revision: $\"\<ESC>"


    Remove the first '|'.

    >
    >
    > More generally, is there a more appropriate way that I can define
    > templates for new files, based on the file name suffix?
    >

    Write all commands you wish to execut in a file and put it in ~/.vim/ftplugin/python.

    :h ftplugin

    -ap

+ Reply to Thread

Similar Threads

  1. autocmd FileType *
    By Application Development in forum Editors
    Replies: 0
    Last Post: 11-22-2006, 12:43 AM
  2. AutoCmd for copy/paste? [vim]
    By Application Development in forum Editors
    Replies: 26
    Last Post: 09-12-2006, 07:41 AM