More VIM tricks

Since my post a few weeks ago, I've been using VI when developing and I only need to access one file, if I need to be workin with multiple tabs at once then I use UtraEdit.(I wrote a review here).

Comment a block of code
I learned this from my friend Brian... say you have 5 lines of code you want to comment out, perhaps you are doing caveman debugging to find where the real problem is..

ctrl-v to go into visual block mode
j down to select the first column in each line
I to insert at begining of line
enter your comment symbol
esc

And there you go! Thanks Brian :)

VIM does orgami
Almost, although you can't make a paper crane with VIM, you can fold your code to make long chunks of code easier to live with. This is something I use in UltraEdit, when I have a really looooooong function that I am not curently working with and I have to scroll up and down to see the code around it.

The syntax to fold a paragraph

zf - create a fold, followed with a text selection command
zo - to open (if your cursor is on the fold line)
zc - to close again (if your cursor is anywhere in that formerly folded thing)
zr - opens ALL folds
zR - opens ALL folds, even nested
zm - close ALL folds
zM - close ALL folds, even nested

I'm still messing with learning folding...I want to see if I can get it to automatically fold at functions in php. Any ideas? the syntax for defining folds is a bit daunting...

Who says VIM can't jump?
If you look at the :help in vim, you see |these blocks| .. use ctrl-] while your cursor is on one of those words in there and it "jumps" there. Sort of like a hyperlink, I guess!

Other misc commands
:S split the window and open file explorer
:sl split the window and open a file
ctrl-w _ max current window
ctrl-w = make all windows the samne

And don't forget, you can still get vim for your Amiga!

Links