Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #62973 > unrolled thread
| Started by | David Kleinecke <dkleinecke@gmail.com> |
|---|---|
| First post | 2015-06-04 10:01 -0700 |
| Last post | 2015-06-05 20:41 -0700 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.c
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Searching online "indent" David Kleinecke <dkleinecke@gmail.com> - 2015-06-04 10:01 -0700
Re: Searching online "indent" Etienne <e.e.f.prudhomme@gmail.com> - 2015-06-04 14:22 -0400
Re: Searching online "indent" "Bill Cunningham" <nospam@nspam.invalid> - 2015-06-05 20:59 -0400
Re: Searching online "indent" Keith Thompson <kst-u@mib.org> - 2015-06-05 20:41 -0700
| From | David Kleinecke <dkleinecke@gmail.com> |
|---|---|
| Date | 2015-06-04 10:01 -0700 |
| Subject | Re: Searching online "indent" |
| Message-ID | <47ee2508-4b6a-427b-8406-af6e4048d97d@googlegroups.com> |
On Wednesday, June 3, 2015 at 6:57:48 PM UTC-7, Stefan Ram wrote: > Do you know a website that is an online beautifier / > reformatter / pretty printer / indent for C that > totally reformats source code (including the choice > of where a line begins and ends) with output in 1TBS? > > For example, it should accept input with all the program on > a long line with 8000 characters on this line (except > preprocessor directives, which are one separate lines) or > one token per line (with many very short lines) and then > create a readable listing with reasonable line lengths from it. > > If you don't know an online version, 2nd best solution would > be a small download for Windows that can be run without > installation (»portable«) with a GUI, say an editor with a > reformatter. Eclipse with a plugin might do this, but I'd > like a download much smaller than Eclipse. Unless I misunderstand the question I think you could do it with sed. I haven't tried though. Thinking about it I see I am probably wrong in general but right for certain setups. For example, the process will vary according to how indents are implemented. Tabs or spaces? Does the display indent each line to same point as the preceding line or must each line be separately indented? The lines all run together problem is solved by replacing each ';' by ";\n" and fixing up the places where this goes wring. That's a simple "replace all" in any editor.
[toc] | [next] | [standalone]
| From | Etienne <e.e.f.prudhomme@gmail.com> |
|---|---|
| Date | 2015-06-04 14:22 -0400 |
| Message-ID | <20150604142255.274b17a0ff4a4f3e7ad765c5@gmail.com> |
| In reply to | #62973 |
On Thu, 4 Jun 2015 10:01:33 -0700 (PDT)
David Kleinecke <dkleinecke@gmail.com> wrote:
> The lines all run together problem is solved by replacing each ';'
> by ";\n" and fixing up the places where this goes wring. That's a
> simple "replace all" in any editor.
Correct me if I'm wrong, but it needs something more than search &
replace if you've got no indentation of blocks. You'll need at least
regex because it's impossible to say if something is in a block
without conditions.
Search & replace could be good to change the indentation style, but
it can't say if those lines:
|if(condition) {
| char foo[] = "bar";
| int lenght = strlen(foo);
| int i;
| for(i=0; i<length; i++) {
->| instruction;
->| instruction;
->|}
|}
are inside a block.
By the way, why someone would format their code in only one line?
--
Etienne
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <nospam@nspam.invalid> |
|---|---|
| Date | 2015-06-05 20:59 -0400 |
| Message-ID | <mktgis$79o$1@dont-email.me> |
| In reply to | #62975 |
"Etienne" <e.e.f.prudhomme@gmail.com> wrote in message
news:20150604142255.274b17a0ff4a4f3e7ad765c5@gmail.com...
> Correct me if I'm wrong, but it needs something more than search &
> replace if you've got no indentation of blocks. You'll need at least
> regex because it's impossible to say if something is in a block
> without conditions.
>
> Search & replace could be good to change the indentation style, but
> it can't say if those lines:
>
> |if(condition) {
> | char foo[] = "bar";
> | int lenght = strlen(foo);
> | int i;
> | for(i=0; i<length; i++) {
> ->| instruction;
> ->| instruction;
> ->|}
> |}
>
> are inside a block.
>
> By the way, why someone would format their code in only one line?
I personally love indent. I will run 'indent -kr -nut' and the file name for
kandr style indentation. And the -nut switch removes all tabs. I tend to tab
alot.
Bill
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2015-06-05 20:41 -0700 |
| Message-ID | <87zj4dsdu3.fsf@kst-u.example.com> |
| In reply to | #63001 |
"Bill Cunningham" <nospam@nspam.invalid> writes:
[...]
> I personally love indent. I will run 'indent -kr -nut' and the file name for
> kandr style indentation. And the -nut switch removes all tabs. I tend to tab
> alot.
Perhaps you can configure your editor to insert spaces when you type
<tab>.
In vim, you can do this by adding
set expandtab
to your .vimrc.
(I'm not expressing an opinion about whether spaces or tabs are better.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web