Welcome Guest, Not a member yet? Register   Sign In
Github code formatting
#1

Hi guys,

This isn't really a question related to anything with codeigniter per se.

I am going through the process of tidying up my code on github to standardize it but I'm a bit miffed with the formatting. I am using sublime text editor and everything is indented nicely, but on github it seems random.

First I want to get through the controllers and lastly the views as this is the most untidy, but when I integrated twig templating it should be much easier to format.

Is there something I should be doing to make it nice and neat. Maybe converting all tabs to spaces or something?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#2

Tabs vs. spaces is an age old discussion, and there are really no drawbacks on either of the two. When there is a drawback is when your code is riddled with tabs AND spaces. Decide which path you want to go, and then convert all tabs to spaces, or space indents to tabs.
Reply
#3

(This post was last modified: 10-11-2015, 04:44 AM by ivantcholakov. Edit Reason: a typo )

@iamthwee

1. If you take code from other authors and you need to modify it, just follow their conventions.

2. Formatting the original code of your project is up to you. But there is no need you to be original and to invent something, choose already an existing set of rules. For example, you may have a look at this: https://github.com/lonnieezell/CodeIgnit...leguide.md
Reply
#4

Thanks ivantcholakov.

My question wasn't to do with coding name styles but more to do with tabs and indentation mirroring on github. I think the solution is what slaxor posted. I either got to convert all to tabs or all to spaces. I'm following the codeigniter style guide.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#5

Related to original question, but does anyone know of a good php formatter plugin for sublime?

So all my controllers and models are nicely formatted the same way. I think this would resolve the issues I'm having with spaces and tabs as well.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#6

I previously used one of the more general-purpose formatters, but had some trouble with it doing a little more than I wanted it to. At the moment, I use Alignment, Line Endingssublime-phpcs, and possibly SublimeLinter 3 to deal with code formatting in Sublime Text 3. It may seem like a lot, but Alignment and Line Endings are very simple, focused tools which do only a couple of things, which makes them perfect for my needs.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB