Which editor to use?

The benefits of highlighting

It is not always easy to keep all your syntax correct - concentrating on the algorithms, calculations, logic and functionality can leave syntax lagging behind. This leads to frustration as all your efforts need to be directed back to the syntax. Far easier to keep the syntax correct as you type and the simplest way to achieve this is for your editor to highlight correct and invalid syntax in real time.

The "Hello World!" program on the syntax page can appear as follows in the Unix/Linux editor Vi (the colour names are indicated in brackets for those who use text browsers, the colour names don't appear in the editor):
 

 #include (navy)  <stdio.h> (purple)
 
 
 char (green)* myfunc() {
   return (yellow) "Hello World!\n";
 }
 
 main() {
   printf("%s" (red), myfunc());
 }

What's the best style for code layout in C?

Some people prefer tabs, some prefer spaces to start lines and indent blocks. Some people start the function block with the brace at the end of the declaration, some start it on the next line. There is no need for any disagreement. The comp.lang.c Frequently Asked Questions advice is simple: Whatever you use, keep it consistent. If you join a project that does things one way, adopt that method. If you start your own project, document how you do things and stick to the conventions you have set out.

Editor aids.

Other editors like Kate have additional aids by using collapsible brackets. When you've got a lot of conditionals, functions or loops, it can be hard to make sure you've closed all the nested brackets. By clicking on the collapsing point, smaller loops can be closed to allow you to see the entire contents of the problematic loop.

+- loop1start {
... code here ...
+- loop2start {
... more code here ...
-} //loop2end
-}//loop1end

Clicking on the + for the second loop in this example collapses loop2 to just show the start line.

+- loop1start {
... code here ...
+- loop2start {
-}//loop1end


This is part of www.codehelp.co.uk Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.