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.



--
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