Automatic wrapping in vim is not very smart. Setting
tw=80 will always
insert a line break no matter if it’s smart to do, e.g. in a string (you
don’t want this in python).
Instead of fiddling with
formatexpr I decided to do line breaks on my
own. Therefor I want vim to show me, when it is a good time to do so.
Adding the below code to
.vimrc, vim will show you when get past the
75th column. So you can decide yourself, when to insert a line break.
highlight ColorColumn ctermbg=magenta call matchadd('ColorColumn', '\%78v', 100)