[Courses] Re: pesky brackets
Mary Gardiner
linuxchix at puzzling.org
Fri Jan 25 12:31:58 EST 2002
On Thu, Jan 24, 2002 at 04:16:03PM -0800, Dreaming Kat wrote:
> 4. especially when 2 & 3 aren't possible, comment each closing bracket.
>
> I do this all the time for anything more than about 6 lines long and
> for the end of all functions. Especially when coupled with proper
> indenting and using a lots of white-space approach, it helps alot.
> if nothing else, you get in the habit of looking back up to where the
> bracket opened to figure out a good comment. :)
In languages like Java and Python where there is a tool that turns your
comments into documentation, it will have to go at the top of the
function or in the specified place, to be picked up.
> a further note on emacs, it will highlight the corresponding open
> bracket when you type a closing bracket. if the opening bracket is
> not on the screen, it will display the line in the status bar if your
> in X.
vim has both these functions too although you have to press some key or
other to get it to match brackets. (if your vim doesn't syntax
highlight, try adding a line that says "syntax on" to your ~/.vimrc)
So list of things you really want in a programmer's editor:
* syntax highlighting (all the language words, like "int" become a
different colour
* context sensitive indenting (when you begin an "if" and hit Enter,
for example, it automatically indents the next line, when you close a
bracket, it moves left).
* ability to match brackets (normally with colour - when your cursor is
on one bracket, the matching one turns a different colour)
A list of editors that provide these:
* emacs
* vim
I'm just hanging around here (I know C), but do people think these merit
an FAQ of some sort?
-Mary.
--
Mary Gardiner
<mary at puzzling.org>
More information about the Courses
mailing list