Back to index
Last updated: 11 January 2020

Fun facts

In this file I have some fun facts and titbits that I have discovered myself or have come across over the years; where applicable I will do my best to give proper credit: if I do not know where I got it from I will note this. If by some chance I fail to do this I am very sorry; I value appreciation, not taking things for granted, being thankful and giving credit where credit is due very very much and it’s always been and always will be something I try my best to do right.

The topics are not restricted to a specific list but whatever I find fun and interesting that I think to add to this file. Maybe in time I'll have a menu of some kind but for now I'm not going to bother; I will keep a last updated at the top like I do everywhere else.

Each fact will be prefixed by 'FUN FACT' with a summary; following that will be a description (differing amounts of detail depending on what is involved) and then an ending prefixed with 'BOTTOM LINE' which will have some interesting things to think about or bear in mind.

FUN FACT: vim: newlines appear like spaces at end of lines in visual mode but not otherwise (and related relations and discrepancies)

If in vim you were to do (in command mode) a search for spaces at end of lines by say '/\s$' any line ending with '\n' (newline char) will not be included. Also if you were to use '$' to go to the end of the line you would be under the last character (e.g. if the line ended with a full stop the cursor would be at the full stop). However if you select it in visual mode you will see that there's a space: exactly where the newline is!

Incidentally in C dialect isspace('\n') == 1; '\n' is known as a newline. But then if you look at regex(7) you will see that character class '[[:space:]]' corresponds to wctype(3) classes. If you then were to check that manpage you'd see:

"space" - realizes the isspace(3) classification function

Then if you check isspace(3) you'll see what I said:

isspace()    checks for white-space characters. In the "C" and "POSIX" locales, these are: space, form-feed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').

But yet doing:

grep -E '[[:space:]]'

On a file will not show blank lines (but see bottom line)! If you do grep '^$' it will (unless of course there are actually spaces there because that's not an empty line!).

BOTTOM LINE: Although newlines can be considered spaces it's not necessarily what you will see all the time; in some contexts it will be but in other contexts it will not be. Looks certainly are deceiving and here even things you cannot see are deceiving! You see what looks like an empty line but if there is a single space there it's not technically empty - but you won't know that unless you search for spaces or otherwise search for empty lines!

This incidentally can be seen when you do a diff of two files where a space was added or deleted from a line but with no other change (coloured diff output will make it easier to see obviously).