When I try to run a script made with Visual Studio Code on Windows in my Ubuntu WSL installation, I get the error:

line 2: $'\r': command not found

I ran into the question below:

How do I fix "$'\r': command not found" errors running Bash scripts in WSL?.

That all makes sense, however is there a way/setting on Visual Studio Code on windows to not have to use the dos2unix utility every time?


In the bottom-right corner of the window there is an indicator that says CRLF or LF [highlighted in green on the picture] which will let you set the line endings for a particular file. Clicking on the text will allow you to change the line endings as well.

enter image description here

CR is a bytecode for carriage return (from the days of typewriters) and LF similarly, for line feed. It just refers to the bytes that are placed as end-of-line markers.

Sources and references:

  • 1
    Thank you for the quick reply. I also appreciate you posting the sources, it was educational and makes sense. – 0siris May 15 '18 at 15:17

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