Wikia

Vim Tips Wiki

Changes: Removing automatic comment leaders

Edit

Back to page

(Standard category names + minor manual clean.)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 19: Line 19:
 
</pre>
 
</pre>
   
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 <tt><C-U></tt> while in Insert mode (in case you do this by accident, [[Recover from accidental Ctrl-U|there are ways to undo it]]).
+
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 <code><C-U></code> while in Insert mode (in case you do this by accident, [[Recover from accidental Ctrl-U|there are ways to undo it]]).
   
Related point: If you want to adjust the indent while in insert mode, you can use <tt><C-D></tt> (to decrease the indent) or <tt><C-T></tt> (to increase it). See {{help|30.4}}.
+
Related point: If you want to adjust the indent while in insert mode, you can use <code><C-D></code> (to decrease the indent) or <code><C-T></code> (to increase it). See {{help|30.4}}.
   
 
==See also==
 
==See also==

Latest revision as of 05:15, July 13, 2012

Tip 129 Printable Monobook Previous Next

created 2001 · complexity basic · author Benji Fisher · version 6.0


If you include the "r" or "o" 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 (in case you do this by accident, there are ways to undo it).

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). See :help 30.4.

See alsoEdit

ReferencesEdit

CommentsEdit

Around Wikia's network

Random Wiki