Vim has the excellent command set tw=79 which will automatically break your lines at 79 characters, however I like (just) my comments broken at 72 characters automatically.
Is there any good way to do this in Vim?
Vim has the excellent command set tw=79 which will automatically break your lines at 79 characters, however I like (just) my comments broken at 72 characters automatically.
Is there any good way to do this in Vim?
I like this one
augroup comment_textwidth
autocmd!
autocmd TextChanged,TextChangedI * :call AdjustTextWidth()
augroup END
function! AdjustTextWidth()
let syn_element = synIDattr(synID(line("."), col(".") - 1, 1), "name")
let &textwidth = syn_element =~? 'comment' ? 72 : 79
echo "tw = " . &textwidth
endfunction
For more inspiration look here.