One line without EOL

5 views
Skip to first unread message

meino....@gmx.de

unread,
Oct 21, 2011, 11:25:05 AM10/21/11
to vim...@googlegroups.com
Hi,

is it possible to create a line of text with vim which
do not contain any \n, \ra ?

Or in other words: The line should contain nothing
more than the visible chars.

I need this to generate test data for testing a VFD...

How can I accomplish this?

Thank you very much in advance for any help!

Best regards,
mcc

Tony Mechelynck

unread,
Oct 21, 2011, 12:21:21 PM10/21/11
to vim...@googlegroups.com

It is possible but definitely not recommended. You must

:setlocal binary noeol

in the file before writing it, and it must contain only the one line (it
is of course not possible to have any line other than the last one end
without an end-of-line mark).

See
:help 'binary'
:help 'eol'


Best regards,
Tony.
--
Behold the warranty ... the bold print giveth and the fine print taketh
away.

meino....@gmx.de

unread,
Oct 21, 2011, 12:38:17 PM10/21/11
to vim...@googlegroups.com
Tony Mechelynck <antoine.m...@gmail.com> [11-10-21 18:32]:
> --
> 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
>
Hi Tony,

thank you very much. I intended to use this "hack" :) only for testing
purposes. I bought a wonderful rtro looking Flourescenz display (VFD)
and have to explore how to connect this to my embedded linux SOC.
I though "vim is useful for doing thing...one only has to know how..."
so asked how to create testdata to be fed into /dev/ttyS0. Only
the line break was not what I want.
Thanks to your help I now know how to avoid it.
And once again: One only needs vim...and a syste to run it. :)

Thank you very much!
Have a nice weekend!
Best regards,
mcc


Taylor Hedberg

unread,
Oct 21, 2011, 12:46:10 PM10/21/11
to vim...@googlegroups.com
Another way to do it would be to edit the file normally in Vim and then
pipe its contents through the Unix command `head` in order to strip off
the final byte (i.e. the final newline). Since you're feeding it to
/dev/ttyS0, you could do something like this:

head -c -1 </path/to/text/file >/dev/ttyS0

Personally, I'd prefer this approach over the 'binary' hack required to
make Vim do what you want, since 'binary' has other (probably undesired)
effects besides enabling you to omit the final newline.

Ben Fritz

unread,
Oct 21, 2011, 5:20:02 PM10/21/11
to vim_use


On Oct 21, 10:25 am, meino.cra...@gmx.de wrote:
> Hi,
>
>  is it possible to create a line of text with vim which
>  do not contain any \n, \ra ?
>
>  Or in other words: The line should contain nothing
>  more than the visible chars.
>
>  I need this to generate test data for testing a VFD...
>
>  How can I accomplish this?
>

The wiki can tell you how to automatically keep the line-ending off of
files which are missing it already:

http://vim.wikia.com/wiki/VimTip1369

Using this tip, you should also be able to simply set 'noeol' to force
a file to save without one.

Benjamin R. Haskell

unread,
Oct 21, 2011, 11:28:46 AM10/21/11
to vim...@googlegroups.com
On Fri, 21 Oct 2011, meino....@gmx.de wrote:

> Hi,
>
> is it possible to create a line of text with vim which do not contain
> any \n, \ra ?
>
> Or in other words: The line should contain nothing more than the
> visible chars.
>
> I need this to generate test data for testing a VFD...
>
> How can I accomplish this?

You can use the 'binary' and (no)'eol' options.

'eol' tells Vim whether to include the final newline in the file. But,
'noeol' doesn't work unless 'binary' is also set.

vim -b +'se bin' filename.oneline

--
Best,
Ben

Benjamin R. Haskell

unread,
Oct 21, 2011, 12:01:49 PM10/21/11
to vim...@googlegroups.com

Whoops, braino:

vim -b +'se noeol' filename.oneline

--
Best,
Ben

Reply all
Reply to author
Forward
0 new messages