Tag Archives: search

Geany: Ignoring .SVN Folders when searching with Find in Files Software & Sites 08 APR 2013

Geany is a text editor using the GTK2 toolkit with basic features of an integrated development environment (IDE). It was developed to provide a small and fast IDE, which has only a few dependencies from other packages. It supports a fair number of languages (like PHP for example) and has most of the features that you would require from a simple IDE, making it a worthy tool for me to use on my sluggish home desktop PC, in place of the a bit too resource heavy, JAVA-powered NetBeans IDE.

By now pretty much all developers should be using some sort of source control system for their code, in my case the preferred one is SVN. The problem now arises that when searching for a string in all my project files using Geany’s Find in Files function, results are returned which point to files in the hidden .svn meta directories. Needless to say, this is pretty useless and definitely something which needs to be addressed.

Luckily for us though, Geany is essentially just pushing through the search request to grep to handle all the heavy lifting, meaning that we can leverage grep’s parameters in order to specify a directory to avoid searching in.

To do this, open up Geany’s Find in Files function via the Search menu, and note the last option in the resulting dialog, right at the bottom – the one that reads Extra options. Check this to enable and then add:


As easy as that. Obviously in this example I want the search to ignore .svn folders. Needless to say, you can modify this to whatever suits your individual needs. Nifty.

Ubuntu: How to jump to the next Search Result in Nano Software & Sites 26 MAR 2013

ubuntu-10-logoGNU nano is a simple terminal-based text editor. Though not as powerful as Emacs or Vim, it is (relatively) easy to learn and use, and has been part of a standard Ubuntu installation for years now.

Ctrl+w is show as the shortcut to initiate a simple text search, but frustratingly enough, it isn’t immediately obvious to jump to the next search result. As it turns out, to do this is simple enough: Alt+w will actually repeat the search, in other words jump to the next search result!

You’ll also notice when entering a search term at the start of a search operation, pressing the up and down arrows will allow you to cycle between terms previously searched on!

Oh, and to toggle searching backwards as opposed to forwards, you’ll need to press Alt+b.

And now you know.

PHP: How to Get the Associated Key from an Array given a Value Programming 06 FEB 2012

If you have a value and you suspect that it might be contained within your array, can you somehow find the key linked to that value if it does exist?

The answer is yes, thanks to the handy array_search function which searches an array for a given value and returns the corresponding key if the search is successful, and false if the value isn’t found in the array.

In practice:

$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array);   // $key = 1;

(Note that similar to strpos validations, you need to make use of the === operator when testing the return value of this function).

The array_search returns the first match it comes across, meaning that if the value is in the array, you’ll only know of one instance. If it is important to know all of the corresponding keys where the value can be found, rather use the array_keys function, but this time with the optional search parameter.

In practice:

$array = array("blue", "red", "green", "blue", "blue");
print_r(array_keys($array, "blue"));
    [0] => 0
    [1] => 3
    [2] => 4