On Feb 24, 12:06 pm, Raúl Núñez de Arenas Coronado <[email protected]>
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/

You mean g/pattern/s/... or %s/..., right?

>
> I've put this in "~/.vim/after/ftplugin/mail.vim
>
> The *.eml file are properly detected as "mail" and the rest of lines of
> "~/.vim/after/ftplugin/mail.vim" are properly executed. In fact, the
> autocommand appear when doing ":au BufRead *.eml", but the autocommand
> is not run.

Correct. The buffer completely read before setting the filetype.
"BufRead" is the wrong event.

>
> I don't want to use "BufEnter" because after the substitution has been
> done it won't match again, so it doesn't make sense running the auto
> command every time I enter the buffer.
>

Right, this is probably a bad idea.

> What am I doing wrong? Is BufRead the problem and then I should use
> another event? Is the placement the problema and I should put the
> autocommand in another file? 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)?
>

One method would be as you suggest: ditch the autocmd. If you want to
use an autocmd, the following events might work:

BufWinEnter
Filetype
BufWritePre
BufRead (from your .vimrc instead of from an ftplugin file)
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to