irritating Ctrl-M s

  • Thread starter Thread starter Bruno van Dooren
  • Start date Start date
B

Bruno van Dooren

Hi all,

i am working a some C++ software that will run both on windows and linux.
development is done on windows with VS .NET 2003.

when i view and edit source files on linux (using Vim), all windows
source files are littered with ^m characters everywhere.

why does the VS editor do this, and what can i do to make it stop doing it?

kind regards,
Bruno.
 
Bruno van Dooren said:
i am working a some C++ software that will run both on windows and linux.
development is done on windows with VS .NET 2003.

when i view and edit source files on linux (using Vim), all windows
source files are littered with ^m characters everywhere.

why does the VS editor do this, and what can i do to make it stop doing
it?

Ctrl-m is a carriage-return (13. == 0xD).

<background ramble>
In the dark old days of teletypes and such, one character - the carriage
return - moved the print-head to the left-most spot, and another - the line
feed (ctrl/j, 10. = 0xA) moved the paper up one click. Some environments use
both characters written "\r\n" C and C++ to signify the end of line.
</background ramble>

Any decent utitility to copy text between platforms should be able to map
"\r\n" to "\n" and vice versa.

It is folly, though, to assume that either platform is wrong not to adopt
the convention of the other.

Regards,
Will
 
William DePalo said:
Ctrl-m is a carriage-return (13. == 0xD).

<background ramble>
In the dark old days of teletypes and such, one character - the carriage
return - moved the print-head to the left-most spot, and another - the
line feed (ctrl/j, 10. = 0xA) moved the paper up one click. Some
environments use both characters written "\r\n" C and C++ to signify the
end of line.
</background ramble>

Any decent utitility to copy text between platforms should be able to map
"\r\n" to "\n" and vice versa.

It is folly, though, to assume that either platform is wrong not to adopt
the convention of the other.

In addition to Will's comments, you can tell VS to save the file with "Unix"
line endings. Once you've saved files with a particular line ending
convention, VS will maintain it (i.e. if it was Unix line endings when the
file was opened, it'll save it that way).

To change the line endings, do File|Save As... and click the little
drop-down arrow on the Save button to bring up the "Save With Encoding"
dialog. Here you can pick an encoding (UTF-8, Code page blah blah, etc) and
you can pick the line endings to use.

-cd
 
great.
thanks for the tip.

not that i care one whit whether it is \r\n or \n, but i want it to look the
same on both platforms.
in that case, \n is the best solution.

Bruno.
 
Back
Top