User Interface – Best Practices for Handling Whitespaces in Configuration Editing

configurationtext processinguser interfacevalidationvariables

For instance, you let the user define the notorious path variable. How do you interpret apppath = C:\Program Files\App?

This looks like a programming language adopted practice to ignore the white spaces and you leave them around the equality mark for readability, but it might be a valid variable value with white space in the application (consider, it is a suffix).

Even keys can contain whitespaces, can't they?

What is the general best practice for my application? If I have:

key-example = value-example

should I interpret the key being "key-example" or "key-example " and the value as being "value-example" or " value-example"?

Best Answer

As a user, I don't expect the whitespace on either side of the equals sign to change the value of the key or the value. See this related question on unix.SE as too how confusing the situation can be.

Don't make it harder on your users, trim whitespace from both the key and the value. If leading whitespace has a real use case for either, then let the user wrap the key or value in quotes.

Related Topic