Count search results in gedit.
gepostet am 20.04.2010Update May 5:
Count results are now being displayed in the Status Bar instead of an alert window. Also, there were a couple of bug fixes. Feel free to download the new version at the provided download link below or at github!
Lately I was looking for a small but missing feature in gedit: I needed to be able to count all occurrances of a selected word. This is a standard feature in many other editors such as Notepad++ in the Windows world, for example. However, I didn’t come across a solution on the net, so I decided to write a little plug-in myself.
What it does: After marking a word the plug-in counts all occurrances of the selection in the current document. It adds a new button to the toolbar and an entry to the menu right in the “Search” section. On top of that you may trigger counting the selection by hitting “CTRL+SHIFT+F”. A small pop-up window will appear and show the results of the search. The results will be displayed in the status bar of the window.
How to use it: Simply mark a word, and have a look at the statusbar: The number of search results will be displayed there.
If you find it useful, feel free to download the plug-in here:
Download gedittools plug-in for gedit.
http://github.com/mmuell23/mmuell23
git clone http://github.com/mmuell23/mmuell23.git cp -r mmuell23/gedittools/* ~/.gnome2/gedit/plugins


May 4th, 2010 at 16:10
Thanks. I’ve wanted for long time for my Ubuntu.
May 5th, 2010 at 09:17
Suggestions: (1) integrate this function into search dialog. (2) when nothing is selected, pop up a dialog to enter text for counting.
Bug: Give wrong number of occurances for some texts (eg, [0]).
May 5th, 2010 at 09:56
Thanks for the bug report!
This is fixed now. Feel free to download again at github:
http://github.com/mmuell23/mmuell23
Or here:
countsearchresults.tar.gz
May 7th, 2010 at 09:57
Most characters giving wrong counts when they are concatenated, eg., ‘dd’, search ‘d’ and gave 1.
Character ‘>’ couldn’t be found.
May 7th, 2010 at 11:57
Hi daxue,
with the newest version this works fine. Tested it using your examples. Did you install the latest version of “gedittools” from the github repository?
git clone http://github.com/mmuell23/mmuell23.git
Then copy all files under gedittools to ~/.gnome2/gedit/plugins
Be sure to delete the old plugin before doing that.
Let me know if it works!
May 11th, 2010 at 16:14
Very useful, ta
Noticed that the Gedit search menu shows the text:
“Count occurances of selection”
The correct spelling is “occurrences”, small point but I’m sure you’d want to know.
Thanks again.
May 12th, 2010 at 05:43
Thanks, Charlie! Will correct that.
September 5th, 2010 at 23:22
Hi,
This is a great tool but it doesn’t work well with large files. when I try to use large files after installing the plugin the gedit is much slower.