
The is really a tip on how to fold any code block including functions. Navigate your cursor somewhere inside of the code block you want to fold, make sure you are in command/normal mode (press escape if you need to) then type zfa}
To save your folds between vim sessions you need to issue the command :mkview otherwise when you close vim your folds will be lost (your folds, not your code). To make life easier on you, you can have your folds automatically saved for you by adding this to your .vimrc file
au BufWinLeave * mkview
au BufWinEnter * silent loadview

One of the smartest people I’ve ever digitally met, Ryan Paul, taught me this awesome tip for doing a project wide search in vim. I needed to look for all occurrences of the patter _Models_ in a PHP project I was working on and you can do it right inside of vim – the best text editor ever invented.
- Open vim and make sure you are in the top level folder of your project by typing :pwd
- Then type :vimgrep YourPattern **/*.php
- To open your search results in their own buffer type :copen
The **/ recursively searches through all your directories for you pattern. :copen opens the search results in their own buffer. You can use the arrow keys to move up and down through the list and hit enter to have it open that result in the main buffer. You can also use :cnext and :cprev to move to the next and previous items in the list. Perhaps you might bind those to keyboard shortcuts so you can move through the search results quickly.

I have been using vim for a couple years and every week it seems I learn some new feature or trick you can do. Recently I learned how to convert a selection to either all uppercase or all lowercase letters.
Convert a visual selection to all uppercase letters.
gU
Convert to lowercase letters
gu