Sometime when I view code on Stack Overflow and some lines are pretty long, I'll have to awkwardly scroll horizontally in order to view the rest of it and then scroll back and continue reading. Like the following example:
public class KeyValuePairJsonConverter : JavaScriptConverter {
public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) {
throw new InvalidOperationException("Sorry, I do serializations only.");
}
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer) {
Dictionary<string, object> result = new Dictionary<string, object>();
Dictionary<string, MyClass> dictionaryInput = obj as Dictionary<string, MyClass>;
if (dictionaryInput == null) {
throw new InvalidOperationException("Object must be of Dictionary<string, MyClass> type.");
}
foreach (KeyValuePair<string, MyClass> pair in dictionaryInput)
result.Add(pair.Key, pair.Value);
return result;
}
public override IEnumerable<Type> SupportedTypes {
get {
return new ReadOnlyCollection<Type>(new Type[] { typeof(Dictionary<string, MyClass>) });
}
}
}
All of my code editors have word wrap turned on to avoid this situation.
I know it's always good to intentionally keep code horizontally within the current view by using line breaks, but you can't expect everyone to do that, and it should be okay not to do it.
What is the reason behind not using word wrap by default in code blocks? Or any code editor for that matter.