Loading ...
Sorry, an error occurred while loading the content.

What am I doing wrong with auto commands.

Expand Messages
  • Timothy Grant
    Hi again, I m working with autocommands to set up differing editing environments depending on what files/buffers I m editing. I use different config-on and
    Message 1 of 2 , Feb 28, 2001
    • 0 Attachment
      Hi again,

      I'm working with autocommands to set up differing editing
      environments depending on what files/buffers I'm editing. I use
      different config-on and config-off files for differing events.

      In general things work quite well. However, I am puzzled by a
      few things. The first is that whenever I try and save a python
      file that has been modified. It appears to be saving things
      twice.

      The second is that when I :wq I regularly see a message
      something like "Document has changed on disk since last save"

      answering "Y" to the prompt is not a huge deal, but it is a
      frustration. I'm including my "not too big" .vimrc and
      vimrc.python-on and vimrc.python-off scripts for any expert
      eyes who care to tell me where I'm not doing things quite
      right.

      Thanks for your input.


      ========================.vimrc==============================
      version 5.0
      " Generic Options
      set nocompatible
      set autowrite
      set writeany
      set ruler
      set history=50
      set viminfo='20,\"50
      set nohlsearch
      set nonumber
      set hidden
      set cmdheight =2
      set shortmess =O

      "GUI and Mouse Options
      set guifont =-schumacher-clean-medium-r-normal-*-*-120-*-*-c-*-iso646.1991-irv
      set mousehide
      set mousemodel =popup

      "Generic Formatting Options
      set tabstop =4
      set backspace =2
      set smartindent
      set mouse =a
      set textwidth =78

      "Clear all auto commands
      autocmd!

      " Python autocmds
      autocmd BufRead *.py source ~/.vim-files/vimrc.python-on
      autocmd BufEnter *.py source ~/.vim-files/vimrc.python-on
      autocmd BufLeave *.py source ~/.vim-files/vimrc.python-off
      autocmd BufNewFile *.py 0r ~/.vim-files/skeletons/skel.py
      autocmd BufNewFile *.py source ~/.vim-files/vimrc.python-on
      autocmd BufWrite *.py !chmod +x %

      " Mutt autocmds
      autocmd BufRead mutt-* source ~/.vim-files/vimrc.mutt-on
      autocmd BufNewFile mutt-* source ~/.vim-files/vimrc.mutt-on

      "Required to be last
      syntax on

      =========================.vim-files/vimrc.python-on===============
      set textwidth =120
      set autoindent
      set smartindent
      set shiftwidth =4
      set expandtab
      set cinwords =class,def,elif,else,except,finally,for,if,try,while
      set number
      set showmatch

      ========================.vim-files/vimrc.python-off==============
      set textwidth&
      set autoindent&
      set smartindent&
      set shiftwidth&
      set expandtab&
      set cinwords&
      set number&


      --
      Stand Fast,
      tjg.

      Timothy Grant tjg@...
      Red Hat Certified Engineer www.exceptionalminds.com
      Avalon Technology Group, Inc. <>< (503) 246-3630
      >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
      >>>>This machine was last rebooted: 43 days 4:04 hours ago<<
    • Benji Fisher
      ... [snip] ... [snip] Try starting vim with the -V flag, so that you can see which autocommands are executed. Alternatively, :set verbose=10. (If you are
      Message 2 of 2 , Mar 1 8:32 PM
      • 0 Attachment
        Timothy Grant wrote:
        >
        > Hi again,
        >
        > I'm working with autocommands to set up differing editing
        > environments depending on what files/buffers I'm editing. I use
        > different config-on and config-off files for differing events.
        >
        > In general things work quite well. However, I am puzzled by a
        > few things. The first is that whenever I try and save a python
        > file that has been modified. It appears to be saving things
        > twice.
        >
        > The second is that when I :wq I regularly see a message
        > something like "Document has changed on disk since last save"
        >
        > answering "Y" to the prompt is not a huge deal, but it is a
        > frustration. I'm including my "not too big" .vimrc and
        > vimrc.python-on and vimrc.python-off scripts for any expert
        > eyes who care to tell me where I'm not doing things quite
        > right.
        >
        > Thanks for your input.
        [snip]
        > " Python autocmds
        > autocmd BufRead *.py source ~/.vim-files/vimrc.python-on
        > autocmd BufEnter *.py source ~/.vim-files/vimrc.python-on
        > autocmd BufLeave *.py source ~/.vim-files/vimrc.python-off
        > autocmd BufNewFile *.py 0r ~/.vim-files/skeletons/skel.py
        > autocmd BufNewFile *.py source ~/.vim-files/vimrc.python-on
        > autocmd BufWrite *.py !chmod +x %
        [snip]

        Try starting vim with the -V flag, so that you can see which
        autocommands are executed. Alternatively, :set verbose=10. (If you are
        using an old version of vim, check the docs first for -V and 'verbose'.)
        Off hand, I would guess that the !chmod has something to do with the
        second problem.

        HTH --Benji Fisher
      Your message has been successfully submitted and would be delivered to recipients shortly.