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

autocmd: variables within pattern are ignored

Expand Messages
  • Mathias Michaelis
    VIM 6.3.62 WINDOWS XP SP2 Hi * In my _vimrc file I put this lines: let $temp = substitute($TMPDIR, ; , , , g ) let $temp = substitute($temp, , / , g )
    Message 1 of 3 , Mar 2, 2005
    • 0 Attachment
      VIM 6.3.62 WINDOWS XP SP2

      Hi *

      In my _vimrc file I put this lines:

      let $temp = substitute($TMPDIR, ';', ',', 'g')
      let $temp = substitute($temp, '\\', '/', 'g')
      let $temp = substitute($temp, ' ', '\\ ', 'g')

      autocmd BufReadPre $temp/RAR* setlocal noswapfile

      Here, $TMPDIR is my environment variable for the temporary
      directory, defined outside of vim. I couldn't use $TEMP or $TMP
      because they are transformed to 8.3 path name convention by some
      mysterious reason and vim doesn't understand this. $TMPDIR is
      however expressed in the normal Windows way, and my own $temp
      variable is "vim language".

      In spite of all this care, vim ignores the autocmd :-(

      However, if I replace $temp by its value within the autocmd line, it
      works.

      But :help autocmd says

      Environment variables can be used in a pattern: >
      :autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab

      I googled and searched the mailing archive, but I don't find any
      solution: What is wrong with my variable within the autocmd pattern?

      TIA
      Mathias
    • Neil Bird
      Around about 02/03/05 10:04, Mathias Michaelis typed ... ... Just as a test case, could you set temp correctly *in* the environment before calling vim, and
      Message 2 of 3 , Mar 2, 2005
      • 0 Attachment
        Around about 02/03/05 10:04, Mathias Michaelis typed ...
        > autocmd BufReadPre $temp/RAR* setlocal noswapfile
        > In spite of all this care, vim ignores the autocmd :-(

        Just as a test case, could you set 'temp' correctly *in* the
        environment before calling vim, and comment out the assignments in the
        vimrc?

        --
        [neil@fnx ~]# rm -f .signature
        [neil@fnx ~]# ls -l .signature
        ls: .signature: No such file or directory
        [neil@fnx ~]# exit
      • Mathias Michaelis
        Hello Neil Bird ... As I said: TEMP is set correctly, but is converted into 8.3 convention -- not by vim, but by Billy s Software. I can do nothing against it.
        Message 3 of 3 , Mar 2, 2005
        • 0 Attachment
          Hello Neil Bird

          >> autocmd BufReadPre $temp/RAR* setlocal noswapfile
          >> In spite of all this care, vim ignores the autocmd :-(
          >>
          > Just as a test case, could you set 'temp' correctly *in* the
          > environment before calling vim, and comment out the assignments
          > in the vimrc?
          >
          As I said: TEMP is set correctly, but is converted into 8.3
          convention -- not by vim, but by Billy's Software. I can do nothing
          against it. Therefore I defined a new variable TMP. Alas, this was
          converted too :-( Therefore, I defined yet another variable: TMPDIR.
          This was not converted anymore :-)

          I can see this conversion in a CMD window by typing

          echo %TEMP%
          echo %TMP%
          echo %TMPDIR%

          as well as within vim by typing

          echo $TEMP
          echo $TMP
          echo $TMPDIR

          vim doesn't make any conversions, even the path separators \ aren't
          changed.

          But wait -- now I found the reason: autocmd _does_ some conversions
          by its own!!! It changes all \ into /. This is why my lines

          let $temp = substitute($TMPDIR, ';', ',', 'g')
          let $temp = substitute($temp, '\\', '/', 'g')
          let $temp = substitute($temp, ' ', '\\ ', 'g')

          are simply too much. I have only to write

          autocmd BufReadPre $TMPDIR/* setlocal noswapfile

          and then all things are fine. Hmmm ... one has to find all this
          magic metamorphosis first :-\

          But nevertheless I have some feature requests for vim under windows:

          - autocmd pattern doesn't recognize short 8.3 path names and can't
          compare them against long path names.

          - autocmd pattern do only compare names, but not interpret their
          meanings. This is why the two paths "C:/bar" and "C:/foo/../bar"
          are treated as different locations. This is why contructions like

          autocmd XYZ $SOME_PATH/../*

          never do work.

          With kind regards and thanks for help

          Mathias
        Your message has been successfully submitted and would be delivered to recipients shortly.