What text editors are in code format?

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

The NetBeans IDE and Intellij IDE have format code . Something like that,

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

}

      

after using this function it will look like this:

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

      

PS I want the same as NetBeans and Intellij offers. I want a text editor because I'm starting with Java and the IDE is not very good for beginners.

+2


source to share


6 answers


Most text editors allow you to associate hotkeys with commands. I am using SciTE and bind the astyle call in the current document to a function key. Astil makes sure to use most languages ​​correctly (it makes C99's ear of pigs the designated initializers, but it's also a good thing). Other source formats are available.



+3


source


Almost any programmer's editor or IDE will reformat the code. You mention NetBeans and InelliJ in your question, but you do not mention why they do not meet your needs. Without further information, all you are likely to get is a list of editors who won't help you.



What are your specific requirements?

+1


source


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

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

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

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

+1


source


Zeus editor can do this by executing a script macro , and these scripts can also be keyboard bound.

+1


source


Note the Chameleon Code . It supports many languages.

0


source


emacs supports fill-region

that will format any selected area of ​​code according to the current mode.

In this context, you can find mark-whole-buffer

and mark-sexp

.


For c-like languages, there is support for a huge panorama of different styles. Read the documentation related to the variable c-file-style

. (Although why no one would use the One True Brace Style outside of me ...)

0


source







All Articles