473,811 Members | 3,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
15 2832
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********@yah oo.comschrieb im Newsbeitrag
news:47******** *******@yahoo.c om...
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...@sc hmitz-digital.de>
wrote:
"CBFalconer " <cbfalco...@yah oo.comschrieb im Newsbeitragnews :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
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************ *************** *******@o42g200 0hsc.googlegrou ps.com>
Spiros Bousbouras <sp****@gmail.c omwrote:
>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...@rwaltma n.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
16178
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
9135
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> <span class="adj">3</span> --
5
12354
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 layout, and I'm finding myself stuck with small white space in between my images where I planned for the graphics to be stacked up right on top of one another. Here's the simple vertical layout: width is 640px, centered with a CSS border. I'd...
0
15195
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 with borders behave counter-intuitively (IMHO) when using style="white-space: nowrap;". Below is a fairly small chunk of XHTML that demonstrates what I'm talking about. What gives? -Mark
5
718
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 preserve formatting (white space and line feeds). However, this is not true when doing the same with the <code> tag listing (it will all be pasted on one line with multiple successive spaces treated as a single space) despite the fact that...
38
24016
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 font) Woudl some of the space character in unicode work? (my html files uses unicode) Xah
12
7228
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 spaces, those are the spaces between the words. But most of what is in the fields has been cut-n-pasted from online forms, and the results can be VERY spread out. I could probably save 80% of the space if I could get rid of the extra white space....
12
4575
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 work for the file which is located in a direcotry with a white space? Thanks!
5
2580
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 the screen, but for some bizarre reason when I try to substring out a series of bytes (aka a fixed-length string or field) from a given option it squashes everything up and corrupts the result.
0
10651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.