Suitable text editor with advanced features


I'm using TextWrangler at the moment to edit code. It is an OK editor, but now I find that I need more advanced features that it seems not to have. I would like that if I write an if statement or while statement, the code below the statement is automatically indented and when I close the if statement, the 'end;' statement should be put at the same level as the if statement. This makes editing lengthy procedures less of a chore. I have utilised editors that have these features, but on Windows. Examples are Borland C++ compiler and Visual Studio 6 and .NET
If anybody has used or uses a text/code editor with such or similar features, then please suggest it. I would appreciate it.
I'm going to try XCode; JEDit ver. 4.0 doesn't seem to do the trick...The language I primarily use is similar to C in structure and syntax. Its called HAL(Hansa Application Language).