cc.
cc.

Reputation: 5633

Which text editors have a format code option?

I'm looking for a basic text-editor with code format like NetBeans or Intellij.

In NetBeans IDE and Intellij IDE you have the option format code. Something like this,

if( a == b )
{
                          bla;
bla;
              bla;

}

after using this feature it will look like this:

if( a == b ){
          bla;
          bla;
          bla;
}

P.S. I want the same thing which NetBeans and Intellij are offering. I want a text editor, because I'm at beginning with Java and the IDE's are not very good for a beginner.

Upvotes: 2

Views: 2107

Answers (6)

emacs supports fill-region which will format any selected region of code according to the current mode.

You might find mark-whole-buffer and mark-sexp useful in this context.


For c-like languages there is support for a vast panoply of different styles. Read the documentation associated with the variable c-file-style. (Though why anyone would not use the One True Brace Style is beyond me...)

Upvotes: 0

jussij
jussij

Reputation: 10580

The Zeus editor can do this by running a macro script and these scripts can also be bound to the keyboard.

Upvotes: 1

poundifdef
poundifdef

Reputation: 19370

I'm not sure if it will change the location of curly-braces (on the same line versus a separate line) but vim (a text editor, available on doze and *nix) will fix indentation.

I find the "==" command to be the most useful. Or, in command mode, going to the top of the file and invoking "=G" will properly indent the entire file.

Summary of vim indentation options: http://vim.wikia.com/wiki/Indenting_source_code

Official documentation of vim indentation options: http://www.vim.org/htmldoc/indent.html

Upvotes: 1

Mark Bessey
Mark Bessey

Reputation: 19782

Almost any programmer's editor or IDE will re-format code. You mention NetBeans and InelliJ in your question, but you don't mention why they aren't meeting your needs. Without more information, all you're likely to get is a list of editors, which isn't going to help you much.

What, specifically, are your requirements?

Upvotes: 1

Pete Kirkham
Pete Kirkham

Reputation: 49331

Most text editors let you bind hot keys to commands. I use SciTE and bind a call to astyle on the current document to a function key. Astyle formats most of the languages reasonable well ( it makes a pig's ear of C99 designated initialisers, but apart from that it's good ) . Other source code formatters are available.

Upvotes: 3

vpram86
vpram86

Reputation: 6010

Check Code-Chameleon. It Supports many languages.

Upvotes: 0

Related Questions