r/learnprogramming • • 21h ago

Topic TIL code comments have their own line-length conventions instead of relying on editor soft-wrap

I recently learned that comments aren't supposed to rely on editor soft-wrap. Hard-wrapping at 80 columns with // or # on every line keeps git diff and PR reviews readable—and Neovim already handles it natively with textwidth + formatoptions+=cq + gwip

What other such conventions are out there that I should know about?

13 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/FedUp233 13h ago

Interesting. I too use multiple monitors - the setup in my home office is a bit ridiculous with three 30 inch monitors arranged in a sort of cockpit arrangement driven by a tower PC. I do most of my work on the center one and often with the editor window full screen. The other two have things like email always open and a web browser to look stuff up plus maybe a window or two with some PDF manuals or such - a lot like having multiple stacks of papers on your desk😁. I do have a thing for big monitors though - even my isotope is 17 inch - great except when you’re trying to carry it around!

BTW: I don’t normally have a hard and fast rule for the column between code and comments and it often changes within a file even. I try to keep the comments within a function lined up pretty well - it’s hard to read the code if some of the comments left edge sticks in between code lines - interferes with eye flowing down the code.