help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Formatting code text


From: Perry Smith
Subject: Re: Formatting code text
Date: Sat, 18 Nov 2006 07:37:14 -0600

On Nov 18, 2006, at 3:42 AM, une wrote:


When writing code in C++ or Java I notice that I can get the code all nicley
aligned and indented correctly by simply adding a comment at the end of each
line of code. As you enter the //, the line of code moves to its correct
alignment. What I have been doing is writing my code and periodically
tidying it up by adding // at the end of every line of code. My question is,
can I speed this aligning and indenting process up by formatting the entire
file using one command? Emacs obviously knows how much each line should be
indented, but doing it one line at a time by adding // is laborious.

PS - I did not mean to cross post, my first post was in the Gnu Emacs forum.
Not sure how this website works yet. Sorry.
-- 

Sounds like you are talking about Meta-Control-Q (in C++ mode but probably in Java mode as well).

Use it when you are sitting on top of, for example, an open curly brace for a function.  Emacs will then reformat the whole function.

I would also suggest doing "apropos" (usually hooked to Control-H a) c-indent

There is a whole bunch of ways to do it.  I find some of them work better than others (at least in older emacs versions)

Just in case you don't know... If you find a function that you like and want to see if it is connected to a key, do C-h, w.  You will be prompted for the function in the mini-buffer.  When you complete it and hit return, it will tell you all the places you can get to that function.

HTH,
Perry Smith ( address@hidden )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems



reply via email to

[Prev in Thread] Current Thread [Next in Thread]