I need help in finding an HTML, CSS, PHP code formatter plug-in for gedit. I've looked into gmate and other plug-ins but I could only find code formatter for Ruby/Rails files.
2 Answers
The way I've done this in the past (though it's been years) is using the External Tools plugin. Essentially, install tested and true command-line utilities that can format the language you need formatted, in the way you like, and then put those commands into the External Tools plugin. Here are the commands I was using:
To format HTML:
tidy -utf8 -i -w 80 -c -q -asxhtml
To format PHP:
php_beautifier -s4 -l "ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)"
I blogged about this years ago: http://www.micahcarrick.com/gedit-html-editor.html

- 9,967
- 3
- 31
- 43
-
is there any way to say php-beautifier where to put the curly brace? I would like to have them on the same line like the function etc... – Karl Adler Apr 18 '13 at 11:29
There's a list of all the plugins available for Gedit here.
It looks like one of their requested plugins is "Code autoformat":
Code autoformat
Automatically apply a chosen coding style while typing. A plugin that lets the user select a coding style (or even pull it from the mode line if possible). While typing the style is applied automatically, e.g., with gtk's style "if (foo) {" would automatically put the "{" in the next line and indent appropriately. Not to be confused with templates (e.g., as in Eclipse), no characters should be inserted automatically. What to autoformat: do, for, if, while argument lists space between function name and left parenthesis add more here ...
So the feature(s) you're looking for might not be avaliable, just yet.

- 464
- 2
- 5
-
Thanks for the reply Erik. When I read the feature request above it hit me and what I actually want is not code formatter but a auto indent tool. After writing my code I want to hit a combination of buttons and just see my code in the opened document auto indented. That's all. – tsega Apr 03 '11 at 15:53