Advertisement
Hi All,
So I've enrolled in my first programming class to get a bit of a feel for it, and I'm having a bit of a problem with my submitted assignments. I'm using vim to write my assignments, and then they are submitted via a WebCT session. My instructor opens the files using notepad (I'm the only student not using Windows - of course) and finds that none of the carriage returns transfer over to notepad, so all my assignments are one huge line, and he grades me 0 unless I print it out and deliver to him in class, which sucks because other than this I have no need to actually travel to campus.
I'm wondering if anyone knows why this happens, and if there is anything I can do about it. Thanks in advance.
So I've enrolled in my first programming class to get a bit of a feel for it, and I'm having a bit of a problem with my submitted assignments. I'm using vim to write my assignments, and then they are submitted via a WebCT session. My instructor opens the files using notepad (I'm the only student not using Windows - of course) and finds that none of the carriage returns transfer over to notepad, so all my assignments are one huge line, and he grades me 0 unless I print it out and deliver to him in class, which sucks because other than this I have no need to actually travel to campus.
I'm wondering if anyone knows why this happens, and if there is anything I can do about it. Thanks in advance.
Advertisement
Advertisement
-
Re: n00b vi question
Thu, September 14, 2006 - 1:57 AMThere are 3 ways to do an end of line. The Unix way, the Mac way and the PC way. Unix/Linux use the linefeed character. Macs use(d?) the carriage return (No idea what OS X uses since it's basically a Unix). The PC for some retarded reason uses both linefeed and carriage return characters for end of line. This makes it key to open files in binary mode on a PC or you end up with screwed up data. Same thing using Copy from the command prompt.
Linux/Linefeed = 0x0D
Mac/Carriage return = 0x0A
PC/retarded = 0x0D 0x0A
Vi is pretty weak. I've purged it from my mind except the sequence to get out of it if accidentally invoke. But many text editors for programming will let you specify the EOL sequence just because of this problem when taking source to different machines.
Now, that said, your instructor is a total dipstick if he's using notepad. And a double dipstick if he didn't know what was going on. Since he's on a PC and an instructor I would assume he had and used at least some version of Visual C++ or Dev Studio gotten at some dirt cheap educational price. It's editor has no problem with text from other standards. And I would assume at some point the code has to actually compile.
There may be some freebie util out there on the web to do the conversion or a text editor for programming that will save it PC style on SourceForge. If not, it's pretty trivial to write one on the PC. I did one a couple of years ago for a similar problem. I'd post it but it's 700 lines. But you could make a fairly simple one for your purposes easy. Open file read it in. scan for 0x0D output the buffer to that point and then output 0x0A, Continue scanning buffer for EOLs and repeat to end of file.
One thing you should be very careful of is the line continuation char backslash \
Most often it is used in macros. The danger is in taking a PC text file using it to a system that uses only a single char for EOL. The backslash tells the compiler to ignore the next char. On a PC the LF CR is read as a single char and the EOL is ignored and your macro continues on the next line. With a Linux compiler that same file unmodified the compiler will ignore the single LF but not the CR so your macro will end without continuing on the next line. And well comedy ensues as you spend nights trying to figure out why your code is broken until you go into disassembly mode and see half of what the line of code should have done is missing.
-
-
Re: n00b vi question
Thu, September 14, 2006 - 10:28 AMThank you, Hypno. That at least gives me a direction to work with.
Do you have any recommendations for unix based text editors? -
-
Re: n00b vi question
Thu, September 14, 2006 - 2:46 PMFor freezies? Lots of them. But would you want to use them? I have heard good things about Eclipse, the Java based development environment from IBM that they gave away to the community. And skills you develop in it are marketable. Then there's tons of people who swear by emacs, another editor I wouldn't touch with a 10 ft. pole no matter how you can kludge it to do anything.
But if you're going to be writing code for a class, at some point it's going to have to build and run, isn't it? And just because it built and ran correctly using standard C is no guarantee of the same thing when you or the instructor has to prove it really works under Windows and you get bit by subtle inconsistencies. Might be simpler just to switch to whatever the class uses for assignments than to add cross-platform issues to your learning curve.
-
Re: n00b vi question
Tue, September 26, 2006 - 5:41 PM
-
Unsu...
Re: n00b vi question
Wed, September 27, 2006 - 12:17 PMYou know, if you're happy with your text editor, there's no reason to change. No reason at all. You might take a look at Elvis and see what you think, but I'm a strong believer in using the tools that you like.
You can use the flip utility to convert the line-endings back and forth between UNIX and DOS. End of problems.
But, really, your prof is a completely untutored dolt if they can't figure this (the simplest and most well-known of file format differences) out. And Notepad? That is utterly lame. :-) Notepad...I have to laugh. Of course, none of this helps you pass the class.
So, Foster, what distro are you using, and if you're using a window manager (like KDE or Gnome) which one are you using? Your distro should contain "flip." I can package up a Debian package for you, or if your distro uses rpm, then we can just do something else to get it to you...like, I'll grab the source. -
-
Re: n00b vi question
Wed, September 27, 2006 - 6:21 PMI'm still getting comfortable with nix in general, cutting my teeth on a fedora install on my hp compaq nx9010. I'll have to check to see if flip is on there. unix2dos came with the distro, but either it didn't work or I didn't do something right.
I don't have any major preference in editor yet, I'm just trying to get reasonably comfortable with vi since it seems to be everywhere.
Yeah, notepad, I know. This is the first programming experience I've had and I already knew of better editors. This guy is supposed to be an industry pro? sigh. -
-
Unsu...
Re: n00b vi question
Thu, September 28, 2006 - 1:02 AMNotepad... I've been snickering all day. :-)
Ok, since you've admitted that you aren't yet attached to vi/vim, I have a solution. Even if you are attached to vi/vim, it is still a solution.
I grabbed the source for Nedit 5.5 and linked it (i486 Linux), zipped it up, and put it here:
www.mousemeadows.com/wally/x...inuxdebs
The file is nedit-5.5.zip and there is a link there to the nedit.org page that will explain nedit a bit. I use nedit for everything, and it doesn't care if you're using gnome, fvwm, kde, or whatever.
So, it is a windowed editor with drop-down menus that is pretty darned sweet.
The really nice thing is that you can open any UNIX/Linux text file and then save-as and you can select Mac, DOS, or Linux for the text file type. So, even if you don't start using it right away, you can still open your files, save them in DOS, and check them out before you send them.
You'll have to open a terminal window to the directory once you unzip the file and issue the following two commands within the unzipped folder:
chmod 755 nedit
chmod 755 nc
nedit is the file to run.
You can put it in /usr/bin, or /usr/local/bin. I don't recommend putting executables in your home directory.
Any questions, yell, or send me an Email wallyw *at* u.washington.edu
It's late, so if I missed anything I apologize in advance. :) -
-
Unsu...
Re: n00b vi question
Thu, September 28, 2006 - 1:03 AMUgh...geekspeak...
"linked it" means making it executable, basically.
-
-
-
-
-