6

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?

fosslinux
  • 3,771
  • 4
  • 28
  • 46
0siris
  • 83
  • 1
  • 3
  • 9
  • See [Create portable, custom editor settings with EditorConfig](https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options#supported-settings) - in particular the `end_of_line` property – steeldriver May 15 '18 at 00:31

1 Answers1

12

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:

pa4080
  • 29,351
  • 10
  • 85
  • 161
  • 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