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
| # | Where | Setting |
|---|---|---|
| 1 | Settings → Preferences → New Document | Format: Unix (LF) · Encoding: UTF-8 (no BOM) |
| 2 | View → Show Symbol → Show End of Line | Shows LF / CRLF at each line end — turn on when in doubt |
| 3 | Settings → Preferences → Language → Tab Settings | For YAML, Python: Replace by space, size 2 or 4 |
| 4 | Settings → Preferences → Backup | Session 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)andUTF-8is what you want for server files. - On the server:
file script.shreports “with CRLF line terminators” if it is wrong;sed -i 's/\r$//' script.shfixes it.
Make WinSCP open files in Notepad++
- WinSCP → Options → Preferences → Editors → Add → External editor → browse to
notepad++.exe. - 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
- Write a two-line script in Windows Notepad:
#!/bin/bash/echo ok, upload it,chmod +xand run it — note the error. - 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.
Join this Course
to be the first to leave a comment.