Editor for C

Discussion in 'OT Technology' started by MobileSuit, Feb 18, 2005.

  1. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    I'm taking CS156 here at Purdue and they want us to code in "vi" or "emacs" but I've been doing most of my coding in notepad. But notepad uses a ^M to do a return (new line) and they dont like that.

    Here are some solutions I want to try but dont have enough knowledge, so I was hoping someone could help me....

    Is there a command for vi or emacs that will remove every single ^M in a file?

    Is there some other free editor I could use that wont put the ^M in the file?

    One of the TA's tried to show me a way to save the file in Wordpad that would remove the ^M's but it didnt work, does anyone know how to do that?

    Thanks
     
  2. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    try running "unix2dos file.c"

    edit: I'm sorry, that's for going from unix to dos (duh)

    if you want, save the file in wordpad, put it on the *nix machine and run
    "dos2unix file.c"
     
  3. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    ehh I'd like to avoid going to the unix computer labs (long walk.... I'm lazy)
     
  4. Muchacho_Gasolino

    Muchacho_Gasolino New Member

    Joined:
    Jul 26, 2004
    Messages:
    364
    Likes Received:
    0
    Location:
    NC
    you could open it up as plain text in openoffice(openoffice.org) and do a search for all ^M's and tell it to replace them with a blank, or it should just select them all and then you press delete. openoffice might fuck it up even more though, dont know much about that

    i just tried it, made a blank document and typed dlkgaslkg ^M alksjdalksdajks ^M alkjdlskajd ^M
    went to find and replace, told it to find all ^M's, it selected them, and i pressed replace without entering anything for replace and they disappeared

    blah openoffice probably uses ^Ms for new lines also though
     
  5. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    well what are you running vi on?
     
  6. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    I use putty to connect to the server and we can run vi and emacs off of it. I just use putty to compile and test the program though. I'm clueless on how to use vi and emacs
     
  7. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    I can give you the file that "might" work on your windows machine. It's part of cygwin so I'm not sure if it requires the DLL but it should work. It's the program to remove all formatting from MS files for use in unix.
     
  8. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    telnet to the server, load your wordpad file to it, and execute dos2unix before you compile on it.
     
  9. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    the dos2unix command didnt work
     
  10. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
  11. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    does that have to be anywhere specific on the server? because I only have access to my folders
     
  12. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,419
    Likes Received:
    592
    cat file.txt | sed 's/\r//' > filenew.txt
     
  13. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,419
    Likes Received:
    592
    P.S. try out TextPad. You can set it to use LF/CR or just LF for a newline, so you can write either dos or unix formatted textfiles.
     
  14. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    it should be in your path. but if you're going to do developing on a unix machine at school with a windows machine at home, I would just get the cygwin suit, or mingw/minsys. as for editors... there are a lot more comprehensive ones out there, like JED, or even eclipse. But this may just seem like a lot of work that may not be worth it if you're not doing a lot of development in C. Hell, just do what Joe_Cool suggested if that's the case.
     
  15. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    I dont do any editing on a unix computer. I do everything on my windows computer
     
  16. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    just use vi, it is not that hard. If you can't figure out how to use that try pico, nano, or joe, they are both editors designed for noobs.
     
  17. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    I downloaded textpad... where in the settings is the LF/CR setting? I cant find it
     
  18. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    :eek3:
    I've got it!

    Thanks a lot guys
     
  19. Shibboleth

    Shibboleth teh mad Plato skillz

    Joined:
    Sep 29, 2004
    Messages:
    1,769
    Likes Received:
    0
    out of curiosity, what did you do?
     
  20. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,419
    Likes Received:
    592
    I think he set TextPad to unix mode.
     
  21. MobileSuit

    MobileSuit New Member

    Joined:
    Jul 29, 2002
    Messages:
    4,285
    Likes Received:
    0
    Location:
    NoVA
    I used textpad and saved it as a unix file. I'm really liking textpad for coding.
     
  22. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    If you'd like to try using emacs again (which I recommend - it's an excellent editor and works great as an IDE), it's handy to look at the Emacs Quick Reference, which has all the basic commands you need to use it as an editor/IDE.
     
  23. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    i normally prefer vi over emacs, just because emacs is so freaking bloated. however, xemacs has a nice code highlighting feature
     
  24. SEPHROTH64

    SEPHROTH64 Guest

    im a CS major at RPI,

    iv been using a program called ultra edit. it lets u save directly to the servers if need be, it does code hightlighting and everything pm me if u want a copy
     
  25. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Yeah, I used to be a VI fan, but I've found lately that emacs is really handy (if a little bloated). And normal emacs has syntax highlighting as well, not just xemacs. I actually run emacs with the -nw flag all the time, since I prefer to use it in the terminal rather than having an X window with the buttons and things.
     

Share This Page