Skip to Content

Notepad++ the safe way for Linux files

A Linux config file edited with Windows Notepad often breaks for one invisible reason: line endings. Windows ends lines with CR LF, Linux with LF only. A shell script saved with CR LF fails with bad interpreter: /bin/bash^M.

Set Notepad++ up once

#WhereSetting
1Settings → Preferences → New DocumentFormat: Unix (LF) · Encoding: UTF-8 (no BOM)
2View → Show Symbol → Show End of LineShows LF / CRLF at each line end — turn on when in doubt
3Settings → Preferences → Language → Tab SettingsFor YAML, Python: Replace by space, size 2 or 4
4Settings → Preferences → BackupSession snapshot on, backup on save

Fix a file that is already wrong

  • Edit → EOL Conversion → Unix (LF), then save.
  • Status bar (bottom right) always shows the current format: Unix (LF) and UTF-8 is what you want for server files.
  • On the server: file script.sh reports “with CRLF line terminators” if it is wrong; sed -i 's/\r$//' script.sh fixes it.

Make WinSCP open files in Notepad++

  1. WinSCP → Options → Preferences → Editors → Add → External editor → browse to notepad++.exe.
  2. Move it to the top of the list. Now double-clicking a remote file opens it in Notepad++; every Save uploads it back automatically.

Useful Notepad++ features for admins

  • Language menu: syntax colours for Bash, YAML, INI, Python, SQL, XML.
  • Search → Find in Files with regular expressions across a downloaded config folder.
  • Plugins → Plugins Admin: Compare (diff two versions of a config) and NppFTP (SFTP straight from the editor) are the two worth adding.

Try it — line endings

  1. Write a two-line script in Windows Notepad: #!/bin/bash / echo ok, upload it, chmod +x and run it — note the error.
  2. Open it from WinSCP in Notepad++, convert to Unix (LF), save — run it again: it prints ok.
Rating
0 0

There are no comments for now.

to be the first to leave a comment.