473,387 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

White space at the end of a line

I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
Dec 3 '07 #1
15 2783
On Dec 3, 7:52 pm, Spiros Bousbouras <spi...@gmail.comwrote:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
//\<no-space>
printf("Never called!\n");
//\<space>
printf("Called!\n");
Dec 3 '07 #2
In article <a8**********************************@e1g2000hsh.g ooglegroups.com>,
<vi******@gmail.comwrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
>//\<no-space>
printf("Never called!\n");
//\<space>
printf("Called!\n");
He said "useful", not "obfuscating"!

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Dec 3 '07 #3
On Dec 3, 5:58 pm, vipps...@gmail.com wrote:
On Dec 3, 7:52 pm, Spiros Bousbouras <spi...@gmail.comwrote:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?

//\<no-space>
printf("Never called!\n");
//\<space>
printf("Called!\n");
I wouldn't call a construct like

//\<no-space>
printf("Never called!\n");

useful. But thanks for the suggestion.

Dec 3 '07 #4
On Mon, 3 Dec 2007 09:52:17 -0800 (PST), Spiros Bousbouras
<sp****@gmail.comwrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
Consider

#define foo \<space>
#define foo \<no_space>

The behaviours are different.

Richard Harter, cr*@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die
Dec 3 '07 #5
On Mon, 03 Dec 2007 18:49:22 GMT, cr*@tiac.net (Richard Harter) wrote:
>On Mon, 3 Dec 2007 09:52:17 -0800 (PST), Spiros Bousbouras
<sp****@gmail.comwrote:
>>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?

Consider

#define foo \<space>
#define foo \<no_space>

The behaviours are different.
What Richard Tobin said.

--
Al Balmer
Sun City, AZ
Dec 3 '07 #6
Spiros Bousbouras <sp****@gmail.comwrites:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
As others have said, the example presented by vippstar isn't what I'd
call *useful*, except perhaps to determine which programmer to fire.

Before I saw that example, I would have guessed that there's no case
where trailing white space is significant. One exception, sort of, is
that a line-joining \ can't be followed by white space (which is a
dumb rule IMHO), but in that case the white space makes the program
illegal.

However, depending on what text editor you use, it might be convenient
to have blank lines indented by the same amount as the non-blank lines
surrounding them. For example (end-of-line marked with '$'):

int x;$
$
x = 42;$

vs.

int x;$
$
x = 42;$

It makes no difference to the compiler, of course,

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 3 '07 #7
rich...@cogsci.ed.ac.uk (Richard Tobin) wrote:
<vipps...@gmail.comwrote:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
//\<no-space>
printf("Never called!\n");
//\<space>
printf("Called!\n");

He said "useful", not "obfuscating"!
This isn't useful either...

puts("Something with a \\<space>
to illustrate a point.");

--
Peter
Dec 3 '07 #8
Spiros Bousbouras wrote:
>
I'm thinking of adding a command to vim for removing white space
from the end of each line of a C source file. Can anyone think of
a situation where such white space might be useful ?
Yes.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com

Dec 3 '07 #9
On Mon, 03 Dec 2007 09:52:17 -0800, Spiros Bousbouras wrote:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
I can't, but of course a danger with such file modifications
is that (some) source control systems/patchers might be fooled into
thinking you had made many changes, for which others working
on the same code might not thank you.
Dec 4 '07 #10
Duncan Muirhead wrote:
Spiros Bousbouras wrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?

I can't, but of course a danger with such file modifications is
that (some) source control systems/patchers might be fooled into
thinking you had made many changes, for which others working on
the same code might not thank you.
I am not familiar with vim, but thi can probably be done without
any alterations. Just use a macro.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 4 '07 #11
"CBFalconer" <cb********@yahoo.comschrieb im Newsbeitrag
news:47***************@yahoo.com...
Duncan Muirhead wrote:
>Spiros Bousbouras wrote:
>>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?

I can't, but of course a danger with such file modifications is
that (some) source control systems/patchers might be fooled into
thinking you had made many changes, for which others working on
the same code might not thank you.

I am not familiar with vim, but thi can probably be done without
any alterations. Just use a macro.
Please expand on that, how could a macro (assuming you talk #define here)
remove trailing whitespace from some source file?
And how could it be added without modifying that source file?

Bye, Jojo
Dec 4 '07 #12
On Dec 4, 2:30 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
"CBFalconer" <cbfalco...@yahoo.comschrieb im Newsbeitragnews:47***************@yahoo.com...Dunc an Muirhead wrote:
Spiros Bousbouras wrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
I can't, but of course a danger with such file modifications is
that (some) source control systems/patchers might be fooled into
thinking you had made many changes, for which others working on
the same code might not thank you.
I am not familiar with vim, but thi can probably be done without
any alterations. Just use a macro.

Please expand on that, how could a macro (assuming you talk #define here)
remove trailing whitespace from some source file?
And how could it be added without modifying that source file?

Bye, Jojo
You assumed wrong.
Yes, it's OT to talk about vim macros.
Theres a thin line between pedantry and stupidity.
Dec 4 '07 #13
Spiros Bousbouras wrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file.
What is wrong with :%s/[\t ][\t ]*$// ? Just define it as a macro.
Can anyone think of a situation where such white
space might be useful ?
No.

(I do this all the time when comparing different
versions of a file to avoid "false positives")

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Dec 4 '07 #14
In article <96**********************************@o42g2000hsc. googlegroups.com>
Spiros Bousbouras <sp****@gmail.comwrote:
>I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
As several people note, this requires defining "useful".

I will add, here, that attempting to make use of "invisible" trailing
white space in C programs, e.g., by writing a slash-slash comment
(in C99) followed by a backslash followed by a blank followed by
a newline, so that the line following this line appears to be
commented out but actually is not, is a bad idea. This is the
case not only because it is obfuscatory, but also because it may
malfunction on some systems.

There are still some (now rare) file systems Out There that are
unable to distinguish between an "empty" line and a "line consisting
only of blanks". In particular, they see a file as a set of
"records" of fixed length. A line shorter than the fixed record
length is blank-padded, and a line exactly the fixed record length
is left alone. (It is physically impossible to have a line longer
than the record length.) In other words, all lines are exactly
the same length, hence the name "fixed length records".

If a C compiler on such a system reads such files, it will[%] remove
all "trailing blanks" from the file itself, as if you (the OP above)
had used your vim command. So an attempt to use C99 comments to
*pretend* to comment out the next line, on such a compiler, actually
*will* comment out the next line. (One can thus use the attempt
to discover whether the compiler is reading fixed-length records
and stripping trailing whitespace from them.)

[% Actually, it could also leave them in, giving surprising behavior
for what the programmer *thought* were trailing backslashes. The
systems I have heard of do delete trailing white-space, though, to
avoid these surprises.]
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Dec 5 '07 #15
On Dec 4, 7:24 pm, Roberto Waltman <use...@rwaltman.netwrote:
Spiros Bousbouras wrote:
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file.

What is wrong with :%s/[\t ][\t ]*$// ? Just define it as a macro.
Nothing. It is one possibility but I'm thinking
of something more elaborate perhaps. Whether it
does anything will depend on whether a boolean
option is set, possibly it will give a warning
for each modified line and to take into account
what Keith Thompson said possibly it will leave
alone lines containing only white space.
Dec 5 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
17
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span>...
5
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple...
0
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
12
by: JA | last post by:
Is there a way to remove all the white space in the fields? I have been using Find-and-replace - looking for 2 or 3 or 4 or 10 spaces and replacing them with none. I don't want to replace single...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
5
by: Richard Maher | last post by:
Hi, Can someone please show me how to tell Firefox to preseve white-space when returning the selectList.option.value attribute? I have change the style so that the white-space is preserved on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.