Skip to content

Instantly share code, notes, and snippets.

@vmanyushin
Last active February 20, 2022 23:13
Show Gist options
  • Save vmanyushin/a02d2d24f2ad552693229c7f3bbc49ac to your computer and use it in GitHub Desktop.
Save vmanyushin/a02d2d24f2ad552693229c7f3bbc49ac to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
/\}/{ctx--}
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
#!/usr/bin/awk -f
# 4 space edition
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
/\}/{ctx--}
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, " ");printf "%s%s\n", id, $0}
@vmanyushin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment