Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was writing a script in vim, dropped my keyboard, and continued coding.

I didn't notice that my cursor changed from the normal _ type cursor, to a [] block. (as if i hit insert in a windows terminal)
I started up my script, and got a /bin/bash^M: bad interpreter error.

With plenty of googling, ^M is the dos carriage return.. but when I hit enter in terminal it looks like a normal carriage return. But bash interprets it as ^M.

I practically keyboard slammed to see what on earth I hit to change this. can someone help me out here?

share|improve this question
    
No, it's just telling you to move to Windows. –  Daniel Beck Jun 6 '11 at 7:34
    
it doesn't count that its a guest in windows 7? =P –  Pcstalljr Jun 6 '11 at 7:50
    
Are you sure that an "Enter" in your VM inserts a CRLF? You can test it with: cat > testcrlf && hexdump testcrlf. When this line is executed in the terminal, press Enter followed by Ctrl + D. You should see just 0a in the right column, not 0a0d. –  Lekensteyn Jun 6 '11 at 8:38
    
see this same behaviour on macbook air. xkcd.com/979 –  hayd Jul 31 at 3:11

2 Answers 2

When you dropped your keyboard, not only did it hit the Insert key, but it managed to enter the :set tx command as well. Run the :set fileformat=unix command in the edit buffer for the file concerned, and then re-save the buffer.

share|improve this answer

To convert a file with CRLF line terminators to LF, run:

sed 's/\r$//' -i your-script-filename

If it's an issue in vim (and not your terminal), look at gVim showing carriage return (^M) even when file mode is explicitly DOS

share|improve this answer
    
Not an answer. He wants to stop writing CRLF when pressing Return on Linux. –  Daniel Beck Jun 6 '11 at 8:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.