On 2009-02-24 19:06 (+0100), Raúl Núñez de Arenas Coronado wrote:
> I want to automatically modify the format of the attribution line and
> some details of the signature when replying to emails. This can be
> done using a couple of simple "s" commands. My problem is on the
> "automatically" part...
>
> For doing the "automatic edition" I've set an autocommand:
>
> autocmd BufRead *.eml /pattern/s/something/otherthing/
>
> I've put this in "~/.vim/after/ftplugin/mail.vim
If you add an autocmd in ftplugin and buffer's context it would probably
be better idea to add buffer-local autocmd:
augroup MyShinyGroup
autocmd! * <buffer> " Remove possible previous ones
autocmd! WhateverEvent <buffer> [...]
augroup END
Or maybe conditionally:
if expand('%:t:e') == 'eml'
augroup MyShinyGroup
autocmd! * <buffer>
autocmd! WhateverEvent <buffer> [...]
augroup END
endif
Buffer-local autocmds in filetype plugins are usually necessary because
user may edit several files of same filetype.
But...
> Given that I only want to do the substitution once at the beginning:
> should I get rid of autocommands and do the job directly in
> "~/.vim/after/ftplugin/mail.vim" (which is what I'm doing right now)?
...in your case I think autocmds are not useful. Just have the ftplugin
check that this is the right kind of file and modify the buffer.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---