Hacker News new | ask | show | jobs
by caribousoup 2211 days ago
Beware: micro sometimes inserts invisible characters into your files. I never figured out why, and it seemed to only be on Debian.

I lost 2 days to troubleshooting weird problems, until less revealed some configs had little droppings of random text sprinkled throughout. I opened them with micro and everything looked fine... then I opened them with nano and I could see and remove the extra characters.

Micro has a great user interface, really. I wish that I could use it, but I don't think it's wise and I will stick with standard nano for quick edits.

4 comments

Could those be non-breakable space characters? Alt+Space generates them in many environments. That caused a lot of grief on MacOS for me until I added a rule in Karabiner to disable the feature.
Do you remember what version that issue happened on? Were you using unicode characters or a non-UTF8 encoding? That sounds like an annoying issue and it would be great to fix it.
This was in 2018, not sure which version. UTF-8 across the board.

I don't remember the details, unfortunately. I think there was a pattern to it, like they were control characters or something. But it silently inserted them, and they were not visible within the editor, but they were visible in nano/less/etc.

Did they just appear as space characters, or did they actually not take up any cells in the editor? Currently some non-displayable characters are rendered as spaces, which is not ideal. I will look into displaying non-displayable characters in a special way (perhaps as `^@`, similar to how Vim does it, or with �, which is meant for this purpose).
I think they were appended to the end of each line, so unfortunately that would make it non-obvious that something was there. If they were rendered as spaces that would explain not being able to see it. Displaying them as � would be an improvement.

Again, this was awhile ago, but I don't think they were single characters, it was a sequence of characters.

Is it possible that it was a matter of changing the line endings? Some applications can be quite sensitive to different line endings… sounds suspiciously like that?

https://en.m.wikipedia.org/wiki/Newline

Have you tried out ne, the nice editor? Also packaged in Debian for quite a while, has syntax highlighting, ctrl+s saves a file etc.
I observed the reverse on Windows. A Powershell profile file edited on vscode, when opened on micro, shows an invisible character (I thought it was space) after every character in it.
That just sounds like a UTF-16 encoded file, which is common on Windows AFAIK. Every second character would be a NUL byte.

Perhaps micro doesn't autodetect encoding? Or you forced it to utf-8?