Wikia

Vim Tips Wiki

Changes: Show how many lines between matching pairs

Edit

Back to page

(Adjust previous/next navigation)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=858
 
|previous=858
 
|next=860
 
|next=860
|created=January 21, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=
 
|author=
Line 27: Line 27:
 
==Comments==
 
==Comments==
 
{{todo}}
 
{{todo}}
*Rename tip to make it a more generic tip on the <tt>'showcmd'</tt> option?
+
*Rename tip to make it a more generic tip on the <code>'showcmd'</code> option?

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

Tip 859 Printable Monobook Previous Next

created 2005 · complexity basic · version 6.0


There are many situations where you may want to count the number of lines between matching pairs of characters, such as parenthesises and braces. This can be especially useful when programming Java, C++, Perl.

Simply set the following:

:set showcmd

After this, in bottomright corner of vim window you will see count of lines currently selected in visual mode (if there are any), among many other useful things.

Now, to see how many lines are between pairs, you set cursor on first pair, enter visual mode and press %. Now in bottom right corner you see desired number.

Or, for certain matched pairs like {...} groups in a C program, you can use a text object. For example, in C code, anywhere within matched braces, enter visual mode and press "iB" to select everything between the braces. The bottom right corner contains the desired count.

CommentsEdit

 TO DO 

  • Rename tip to make it a more generic tip on the 'showcmd' option?

Around Wikia's network

Random Wiki