Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. – hayd Jul 31 '14 at 3:11

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .