Quantcast

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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

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 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

Ben Fritz
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

John Beckett-2
In reply to this post by Paddy
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
Loading...