NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code formating on per project basis


Joined: 30 May 2006
Posts: 33
Reply with quote
It is quite a frustrating, that PHPEd supports only one global code formatting settings.
When working on multiple projects I often need to switch between projects.
Ironically, the longer I work with PHPEd, the more often I need to switch to various code formating Smile

For example we have a PHP + angular project.
Angular JS files always do their standard formating: 1 tab = 2 spaces, no TABS chars, no optimal fill.
Then I need to modify PHP file on the same project which uses: 1 tab = 1 TAB character, optimal fill.
It's really difficult to find proper formating settings in PHPEd for both at the same time - not possible globally, not to mention on per project basis.

PHPStorm allows overriding such a global settings with local per-project based settings.
Thus, it allows to set JS files to 1 tab = 2 spaces without interfering with JS files in another projects.

This feature would make huge step forward and make PHPEd much more competitive.
BTW - My colleagues also refused to use PHPEd due to this missing feature, even though I told them that they suck and debugging is more important than formatting Smile
View user's profileFind all posts by lubosdzSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7835
Reply with quote
and how would per-project tab setting help have different settings for the files in the same project?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 06 Jul 2016
Posts: 6
Reply with quote
Maybe, it could be done like all others do it too? Smile

http://editorconfig.org/

Quote:
EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.


For me, one aspect that is more important than working with different IDEs or Editors, is: When working on an OS project that uses for example tabs for indentation, (I personally use 4 spaces) I have to switch my settings. Also when back working on my own projects, I have to switch it back. And regarding that, you surely can imagine that it is a really, unnecassary culprit when simultaneously working on files from both project types.

I'm very happy with PhpED and its toolset. Only this one is missing for me!

Thanks for mailing me and asking for improvements.

( and greetings to lubosdz, I feel with you Smile )
View user's profileFind all posts by eyeballSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7835
Reply with quote
guys, it's still unclear what you need.
According to the description, you have two set of files in one project. One set has 2spaces as an indentation step and remaining has 1tab per indent.
On the other hand, per-project settings would allow to set different spaces/tabs for different projects. Okay. What's about files in one project? Isn't it clear it won't help?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
inspiration links


Joined: 30 May 2006
Posts: 33
Reply with quote
It's quite often a case that various scripting languages apply it's own formatting rules.
PHPStorm's implementation is very flexible, that's why I took it as an good example.
It supports code formatting on

1. GLOBAL + PER SCRIPT TYPE basis
2. PER PROJECT + PER SCRIPT TYPE basis.

Rules 1. are always applied unless custom rules 2. are defined.

Thus it is possible to apply:
- in project 1 global formating for all PHP files, but for JS files (e.g. angular) we need to apply specific formating only for this one project. So we'd need to define JS custom formating only in project1.
- in project 2 specific formating for PHP files and specific for coffee scripts (e.g. node implementation). Python script may use global formating. We'd need custom formating rules for COFFEE and PHP files.

Screenshot examples:
https://postimg.org/image/tvyr18dxz/
https://postimg.org/image/p59hk2oiv//

video - code formating:
https://www.youtube.com/watch?v=xIxDar8CbJA

other inspirative links:

inline formating docblocks:
https://www.jetbrains.com/help/webstorm/2016.1/reformatting-source-code.html

reformating source code:
https://www.jetbrains.com/help/phpstorm/10.0/reformatting-source-code.html

code styling - PHP
https://www.jetbrains.com/help/phpstorm/2016.1/code-style-php.html


In my experience, this is really quite complex implementation.
But it's been a source of lot's of frustration during last 2 years since we moved to many smaller commercial projects and need to do often switch.
So current solution is only to turn off all code formatting features (optimal fill, use tabs, ...) otherwise it would be impossible to review committed changes.
I can only use current PHPEd's global formatting settings in my own projects, but almost never on team projects.
Any chance to support this .. ?
View user's profileFind all posts by lubosdzSend private message


Joined: 06 Jul 2016
Posts: 6
Reply with quote
IMHO, the best solution would be to support http://editorconfig.org/ editorconfig files.
These is a list of IDEs, Editors that use it:
    Atom
    Brackets
    Coda
    Eclipse
    Emacs
    Geany
    Gedit
    jEdit
    Komodo
    NetBeans
    Notepad++
    PhpStorm
    PyCharm
    SublimeText
    textmate
    Vim
    Visual Studio
    Visula Studio Code

On the website it is short but detailed explained how this works. PhpED needs to lookout for .editorconfig files in each of its project directories, and if found one, parse it. After parsing all those files, if there are multiple, there is a final result, that needs to be translated / transmitted into PhpEDs Editor settings.

When activating another project, the parsing needs to be repeated. Come on dmitri, PhpEd scans and parses half of my PC when I open a project, and it presents me everything what may have changed, even when changed outsite of PhpED, in lightning speed. I believe you guys are able to implement this in a few hours. Please have a read there on the website. It is easy, unobtrusive and very powerful. And nothing had to be set in PhpEDs settings. Every thing goes automagicaly. Only one thing may be added to the editor settings or project settings: the possibility to ignore the .editorconfig files for a particular project.
View user's profileFind all posts by eyeballSend private message


Joined: 22 Apr 2014
Posts: 23
Reply with quote
That would be awesome if PHPEd could support http://editorconfig.org/

It's the first time I saw this, but it would be the best solution I could imagine. Thanks for sharing.
View user's profileFind all posts by infcSend private message
Guru master

Joined: 24 Jul 2009
Posts: 704
Reply with quote
I would really like projects to remember the number of spaces. Currently I set PhpED to 2 spaces and then do a double indents/outdents when it needs to be 4 spaces (tedious).

I do also work on some projects where according to the standards, the number of spaces varies between different file types. PHP and HTML 4 spaces, CSS and Twig 2 spaces, etc.

So being able to set the number of spaces by file type on a per project basis would be nice, but I would be happy to be able to set it just for individual files, just like you can set the encoding.
View user's profileFind all posts by plugnplaySend private message


Joined: 06 Jul 2016
Posts: 6
Reply with quote
VERY GOOD NEWS HERE: http://www.nusphere.com/products/php_ide_editorconfig.htm Very Happy
View user's profileFind all posts by eyeballSend private message
Code formating on per project basis
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic