Friday, March 26, 2010

Re: End of line marker?

On 26/03/10 13:16, Jürgen Krämer wrote:
>
> Hi,
>
> KKde wrote:
>>
>> One of my friend is facing problem, where in vim the end of line is
>> affixed with some box like character. Remember 'set list' is off.
>>
>> Is there some setting that is causing to show some character at the
>> end of line?
>
> this can happen when you edit a with DOS line endings, i.e., carriage
> return plus line feed, the 'fileformats' does not contain DOS, but only
> UNIX or MAC, and if the 'isprint' option contains 13 (the numeric code
> for carriage return) or 10 (the one for line feed) or a range including
> 13 or 10.
>
> In this case Vim wants to show you that there is an additional carriage
> return or line feed. Normally they would be displayed as ^M or ^J, but
> because the corresponding numeric value is included in 'isprint', Vim
> tries to show a glyph from the current font. Most fonts don't have a
> glyph for control characters, so a substitue is chosen -- which, e.g.,
> on Windows happens to be a rectangle.
>
> Regards,
> Jürgen
>

Yes, and it could also happen with

:set fileformats=dos,unix

if you try to edit a file whose last line lacks an end-of-line. Then Vim
will treat that file as Unix-style and display the carriage returns
which are part of the Dos-style line endings (normally as ^M, but as a
hollow box, reverse-video question mark, or other placeholder if
declared "printable" by the 'isprint' setting). If this is the case,
then make sure that you have (or that your friend has) a Vim version not
earlier than 7.2.040 (the latest to date is 7.2.411) and open the file with

:e ++ff=dos filename

This way, either CR+LF ("Dos-style" EOL) or LF-only ("Unix-style" EOL)
will be seen as an end-of-line when reading, and all lines (including
the last one) will get CR+LF when writing.

Note that some other programs such as Notepad have been said to
(mistakenly) display an "empty line" after the last line when the latter
has a proper end-of-line marker.


Best regards,
Tony.
--
GALAHAD: No. Look, I can tackle this lot single-handed!
GIRLS: Yes, yes, let him Tackle us single-handed!
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments:

Post a Comment