* Formatting code text
@ 2006-11-18 9:42 une
2006-11-18 13:37 ` Perry Smith
0 siblings, 1 reply; 3+ messages in thread
From: une @ 2006-11-18 9:42 UTC (permalink / raw)
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.
--
View this message in context: http://www.nabble.com/Formatting-code-text-tf2658909.html#a7416552
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Formatting code text
2006-11-18 9:42 Formatting code text une
@ 2006-11-18 13:37 ` Perry Smith
0 siblings, 0 replies; 3+ messages in thread
From: Perry Smith @ 2006-11-18 13:37 UTC (permalink / raw)
Cc: Help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 1721 bytes --]
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 ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )
Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems
[-- Attachment #1.2: Type: text/html, Size: 6932 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Formatting code text
[not found] <mailman.786.1163845620.2155.help-gnu-emacs@gnu.org>
@ 2006-11-19 19:34 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2006-11-19 19:34 UTC (permalink / raw)
> 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.
Hitting TAB does that as well, in a less roundabout way.
Take a look at indent-region as well.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-19 19:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-18 9:42 Formatting code text une
2006-11-18 13:37 ` Perry Smith
[not found] <mailman.786.1163845620.2155.help-gnu-emacs@gnu.org>
2006-11-19 19:34 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.