On 18/04/11 01:02, Ben Schmidt wrote:
On 18/04/11 6:57 AM, Tony Mechelynck wrote:
On 17/04/11 13:54, Ben Schmidt wrote:
E488 is "Trailing characters"

Perhaps it is occurring because your script has DOS line endings on a
Unix/Mac system. That frequently causes these kinds of errors. Ensure
your script containing the autocommand is saved with Unix line endings
and it should go away. Vim scripts with Unix line endings work on all
systems.

Ben.

I thought it was because of the ^M (an actual carriage-return)
intentionally made part of the substitute pattern; replacing it with
\r would then cure the problem.

Mmm. Sorry. I hadn't read the thread carefully enough. The problem was
the <CR>. An autocommand is not like a mapping; it is not a list of
keystrokes executed in a particular mode; it is an Ex command.
Consequently, something like

au ... :%s/^M//g<CR>

has trailing characters, beginning with <, because the <CR> isn't
interpreted as a press of Enter, it is interpreted as part of an Ex
command. A similar thing can happen if a DOS line ending is found in the
file, because a ^M at the end after the g is just as illegal as a
substitute flag.

Someone already gave the correct answer: the <CR> should be left out,
and the : is unnecessary too, but :silent should be used to avoid the
press enter prompt.

au ... silent %s/^M//g

The ^M in the middle is fine. Though \r is more readable, IMHO, so it
would be best to write.

au ... silent %s/\r//g

Ben.





Yeah, I suggested au <something> %s/\r//ge (e-flag just in case there wasn't any ^M) but maybe I forgot the % range. There ought to be at most one line of message so by itself this should not produce a more-prompt. Of course adding "silent" makes even more sure that it won't.

Best regards,
Tony.
--
Two men came before Nasrudin when he was magistrate.  The first man
said, "This man has bitten my ear -- I demand compensation."  The
second man said, "He bit it himself."  Nasrudin withdrew to his
chambers, and spent an hour trying to bite his own ear.  He succeeded
only in falling over and bruising his forehead.  Returning to the
courtroom, Nasrudin pronounced, "Examine the man whose ear was bitten.
If his forehead is bruised, he did it himself and the case is
dismissed.  If his forehead is not bruised, the other man did it and
must pay three silver pieces."

--
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 via email to