Using Vim to Count Patterns

This page has moved.  Please update your links:

The other day, I posted a trick on using Vim with flat files.  Well, today, I wanted to count the number of times certain data conditions appeared in my file.  I created statistics on my program to show the count, but I wanted to check them to make sure the code was right.  I found this command would do the trick in Vim:


The “s” is the part that does a search and replace, but the “n” tells it to only count the matches rather than replace it with anything.  So, if I wanted to count the number of lines with “0” in the 123rd position, I would use this:


Here is where I found the trick:

Wiki Technology – Vim: Count number of matches of a pattern

Posted in Vim. 1 Comment »

Extracurricular at Oracle

This page has moved.  Please update your links:

I came across a link to Team Oracle the other day.  I didn’t realize that they have their own Air Show team!  I’ll have to watch the schedule to see if I can catch them in our area.

While we are on the topic, I did already know that Oracle has their own Yacht Racing team.  You can check out BMW Oracle Racing here.

Now, we just need a Basketball team!  We could have Oracle Arena and the mascot could be the CPU Chips.  Maybe that is too much imagination.

IniFiles in VB.Net

This page has moved.  Please update your links:

I have been coding a VB.Net interface to PeopleSoft, and needed the ability to read and write INI Files. This link really helped me out: INI Files Will Never Die: How-To in .NET

Evaluate in SQR

This page has moved.  Please update your links:

I did a quick little test on the Evaluate syntax in SQR.  I can’t ever remember how the break statement works and if it is required.  So, here is the test —

Here is the code:

  move 1 to #test
  while #test < 6
    show 'Test = ' #test
    evaluate #test
      when = 1
      when = 2
        show 'evaluated as 1 or 2'
      when = 3
        show 'evaluated as 3'
      when = 4
        show 'evaluated as 4'
        show 'evaluated as other'
    add 1 to #test

Here is the output:

Test = 1.000000
evaluated as 1 or 2
Test = 2.000000
evaluated as 1 or 2
Test = 3.000000
evaluated as 3
Test = 4.000000
evaluated as 4
Test = 5.000000
evaluated as other

Vim Search in Flat Files

This page has moved.  Please update your links:

I have been working with Flat Files recently, and I found Vim Search patterns can help with finding certain conditions within the file.  This pattern works very well:


Searches for n number of the preceding pattern.

For example, say you want to find any lines in the file that have a “2” in the 51st position of the file.  You can use this pattern:


So, this matches 50 characters of anything and a “2” following.


Softpanorama: Vim Regular Expressions