sponsor Vim development Vim logo Vim Book Ad

basic Tip #129: Removing automatic comment leaders

 tip karma   Rating 12/11, Viewed by 1090 

created:   October 7, 2001 19:16      complexity:   basic
author:   Benji Fisher      as of Vim:   5.7

     If you include the "r" flag in the 'formatoptions' option (:help 'fo' , :help fo-table ) then the comment leader is inserted
automatically when you start a new line in a comment.  For example, in TeX the "%" character is the comment leader,
and you might type

% This is a tex file.
% The comment leaders on all lines but the first were generated automatically.
% This is the last line of the comment, but Vim will insert the comment leader on the next line.
%

You can get rid of the comment leader (along with anything you may already have typed on the line) without affecting
the indent, if any, by typing "<C-U>" while in Insert mode.

     Related point:  if you want to adjust the indent while in Insert mode, you can use "<C-D>" (to Decrease the indent)
or "<C-T>" (to increase it).  In the docs for Vim 6.0, this is described in the users' manual, :help 30.4 .

 rate this tip  Life Changing Helpful Unfulfilling 

<<grep, diff, patch, idutils, etc. for Windows systems | disabling default ftplugins >>

Additional Notes

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo