When I am typing a long code comment in VIM, I manually judge when each comment line reaches 80 characters, then manually typically press < enter >< tab >//< space > and continue on. Likewise it is awkward editing comments, adding or removing text.
// The comments I have to use
// look like this
Ideally, I’d like some kind of comment mode, where you type text, and the 80 line character limit and the // symbols are sorted out automatically. Does anything like this exist?
You can turn on formatting options with
set formatoptions=tcq(with tcq each representing an option, there are others as well). Useh formatoptionsto see what the various flags are.In this case you probably want to use
set fo+=a.Personally though, I prefer to just type my comments normally, then when I’m done run
gqip.gqis the formatting command,ipfor in paragraph. Make sure the comment block is not next to code though or it will suck that up when reformatting your comment.