Wikia

Vim Tips Wiki

Changes: Apply range to any command that does not accept ranges

Edit

Back to page

(Adjust previous/next navigation)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=1151
 
|previous=1151
 
|next=1154
 
|next=1154
|created=February 26, 2006
+
|created=2006
 
|complexity=basic
 
|complexity=basic
 
|author=Yakov Lerner
 
|author=Yakov Lerner
Line 20: Line 20:
 
</pre>
 
</pre>
   
That is, you add <tt>g/^/</tt> between the range and the command.
+
That is, you add <code>g/^/</code> between the range and the command.
   
 
==Comments==
 
==Comments==

Latest revision as of 06:10, July 13, 2012

Tip 1153 Printable Monobook Previous Next

created 2006 · complexity basic · author Yakov Lerner · version 6.0


Some commands do not accept ranges, but you want to execute them for every line in the range.

This trick allows to apply the range to any command that does not accept range directly:

:n1,n2 g/^/ command

That is, you add g/^/ between the range and the command.

CommentsEdit

Around Wikia's network

Random Wiki