Created
May 3, 2011 22:12
-
-
Save lytithwyn/954374 to your computer and use it in GitHub Desktop.
code for PHP Code Formatting with sed blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this line reads the whole file in so we can do multiline substitution | |
:a;N;$!ba; | |
# this gets rid of our 5 line breaks between functions | |
s/\n\n\n\n\n/\n\n/g | |
# this puts curly braces on the same line with the control structures/function definitions to which they belong | |
# be aware that if there is a set of lines like this: | |
# | |
# if(myTest) //here's some documentation | |
# { | |
# next line of code | |
# ... | |
# | |
# the curly brace will end up in the end of the comment; watch out for that | |
s/\n[ ]*{/ {/g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function myFunc($arg) { | |
print("some stuff"); | |
if($arg == 2) { | |
print("Arg is 2!"); | |
} | |
} | |
function myFunc2() { | |
print("I'm func 2!"); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function myFunc($arg) | |
{ | |
print("some stuff"); | |
if($arg == 2) | |
{ | |
print("Arg is 2!"); | |
} | |
} | |
function myFunc2() | |
{ | |
print("I'm func 2!"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment