views:

148

answers:

6

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.

A: 

Check Code-Chameleon. It Supports many languages.

Aviator
+2  A: 

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.

Pete Kirkham
+1 on using scite's external commands to invoke a beautifier -- I go for GNU indent. I know of Windows people that swear over Notepad++. And I guess emacs would'nt qualify as a "basic text-editor".
codehead
+1  A: 

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?

Mark Bessey
The same thing which NetBeans and Intellij are offering.I want a text editor, because I'm at beggining with Java and the IDE are not very good for a beginner.
cc
While I can respect your desire to learn the language from the basics, that shouldn't preclude you from using the IDE for editing. You've already got the tools, you may as well use them.
Timbuck
+1  A: 

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%5Fsource%5Fcode

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

rascher
I like ggvG= in visual mode to reindent/pretty the whole file.
Nick Presta
A: 

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

jussij
A: 

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...)

dmckee