Archive for July, 2010

Favorite Vim Tips

Posted on July 30th, 2010 in Vim | No Comments »

Quickly Indent Blocks Of Code

Vi Gang Sign

  1. Make sure you have :set cindent
  2. Put your cursor on an opening { or closing }
  3. Press =%
  4. All the code in the block is nicely indented

Searching Through Projects With vimgrep

Search through all the PHP files in a project.
1. Make sure you are at the root of your project in vim (type :pwd to see) if you are in the wrong dir then type :cd /path/to/project
2. :vimgrep pattern **/*.php

Examples:

Find the pattern “findMe” and don’t jump to the first match. Use the j flag to prevent jumping to the first match

:vimgrep /findMe/j **/*.php

Find the pattern “findMe” but match on case as well (case-sensitive)

:vimgrep findMe\C **/*.php

Find the pattern “findMe” without regard to case (case-insensitive)

:vimgrep findMe\c **/*.php

Organize With Pathogen

This is the best plugin ever for keeping your other vim plugins neat and
organized. Gone are the days of shotgunning doc and plugin files in multiple
directories. Now a plugin and all its related files can stay together.
Go here to get pathogen from vim.org

Exclude Individual Pages From WordPress Searches

Posted on July 21st, 2010 in Uncategorized | No Comments »

There is plenty of information on how to exclude certain categories from WordPress Searches but it is very hard to find anything on how to exclude individual posts or pages from the search results. All you need to do is add a search filter to your functions.php file in your WordPress theme that looks like this:

function searchFilter($query) {
  if ($query->is_search) {
    $query->set('post__not_in', array(13,14,15));
  }
  return $query;
}
add_filter('pre_get_posts','searchFilter');

Just change 13,14,15 to whatever page (or post) ids you would like to exclude from the search. Do not put the numbers in quotes.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes