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

Windows : autocmd fires up on right-click "edit with vim", not on double click

Expand Messages
  • Paddy
    Hi all, I m having an issue running Vim 7.3 on my Windows 7 workstation. I m using it partly for editing todo files, for which I created a simple custom syntax
    Message 1 of 3 , Aug 2, 2012
    • 0 Attachment
      Hi all,

      I'm having an issue running Vim 7.3 on my Windows 7 workstation. I'm using it partly for editing todo files, for which I created a simple custom syntax file. I use the following command to use my syntax file on *.todo files, in my vimrc :

      $ au BufNewFile,BufRead *.todo set ft=todo

      This works perfectly when I open the files using right-click "Edit with Vim" entry, but it doesn't when I double click the file in the explorer, or use the app launcher launchy (http://launchy.net) to open the file (":set ft" returns nothing, and the syntax highlighting is indeed not applied).

      I made some tests and tried to apply the filetype to txt files as well using the following command in my vimrc :

      $ au BufNewFile,BufRead *.txt set ft=todo

      ...and it's working great in both cases. Any idea what I'm missing here ? I made some research this morning, went through some help files and tried other autocmd events, but didn't find anything better.

      Thanks for your help !
      Cheers,

      Paddy

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Ben Fritz
      ... I ve never had any problems with Windows file associations (double-click in explorer). What is the command invoked to launch the file in Vim? Perhaps you
      Message 2 of 3 , Aug 2, 2012
      • 0 Attachment
        On Thursday, August 2, 2012 4:55:33 AM UTC-5, Paddy wrote:
        > Hi all,
        >
        > I'm having an issue running Vim 7.3 on my Windows 7 workstation. I'm using it partly for editing todo files, for which I created a simple custom syntax file. I use the following command to use my syntax file on *.todo files, in my vimrc :
        >
        > $ au BufNewFile,BufRead *.todo set ft=todo
        >
        > This works perfectly when I open the files using right-click "Edit with Vim" entry, but it doesn't when I double click the file in the explorer, or use the app launcher launchy (http://launchy.net) to open the file (":set ft" returns nothing, and the syntax highlighting is indeed not applied).
        >
        > I made some tests and tried to apply the filetype to txt files as well using the following command in my vimrc :
        >
        > $ au BufNewFile,BufRead *.txt set ft=todo
        >
        > ...and it's working great in both cases. Any idea what I'm missing here ? I made some research this morning, went through some help files and tried other autocmd events, but didn't find anything better.
        >
        > Thanks for your help !
        > Cheers,
        >
        > Paddy

        I've never had any problems with Windows file associations (double-click in explorer). What is the command invoked to launch the file in Vim? Perhaps you can get this with the "ftype" and "assoc" windows shell commands, or by examining the registry:

        http://vim.wikia.com/wiki/Windows_file_associations

        Can you reproduce this problem with a very minimal .vimrc, preferably with just enough in it to set up the autocmds in question?

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • John Beckett
        ... It s a long time since I thought about this, but while your command should work, I think the proper procedure is to create file
        Message 3 of 3 , Aug 3, 2012
        • 0 Attachment
          Paddy wrote:
          > I'm having an issue running Vim 7.3 on my Windows 7
          > workstation. I'm using it partly for editing todo files, for
          > which I created a simple custom syntax file. I use the
          > following command to use my syntax file on *.todo files, in my
          > vimrc :
          >
          > $ au BufNewFile,BufRead *.todo set ft=todo

          It's a long time since I thought about this, but while your
          command should work, I think the "proper" procedure is to create
          file $HOME/vimfiles/filetype.vim (on Windows) with content like:

          if exists("did_load_filetypes")
          finish
          endif
          augroup filetypedetect
          au! BufNewFile,BufRead *.csv setf csv
          au! BufNewFile,BufRead *.todo setf todo
          augroup END

          My guess is that you are invoking a different Vim, or invoking
          the same Vim with some different environment. When it works, use
          the following to capture the scripts that have been loaded. Then
          do the same when it does not work and compare.

          :set nomore
          :redir @a
          :scriptnames
          :redir END
          :new
          :put a
          :set more

          John

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.