On 17/04/11 06:51, Michael(Xi Zhang) wrote:
I want use %s/^M//g to delete the ^M in *.c files.

In vimrc file, I added


au BufRead *.c  :%s/^M//g<cr>


But Vim give me a E488 error. If I use

au BufRead *.c  :%s/^M//g  (delete the <cr> from above)

It will be no error, but I need to press Enter to continue.


Anyone could give me a hint?


Thanks!


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

E488 is "Trailing characters"

^M is a real Enter code, I don't know how it will be handled. Try using

        au BufRead *.c %s/\r//g

instead; or to delete ^M (carriage return) only if found at the end of a line (just before a linefeed character), but also in other common C/C++ source files,

        au BufRead *.c,*.h,*.cpp %s/\r$//

Note that if _all_ lines including the last end in CR+LF, Vim (with 'fileformats' [plural] set to the default) should detect it as Dos format and in that case the latter substitute won't find anything to replace -- so I think it would be prudent (in both cases) to add an e flag at the end (see :help :s_flags )


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
60. As your car crashes through the guardrail on a mountain road, your first
    instinct is to search for the "back" button.

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