Automatically run commands on opening a file


I’m guessing I need to edit my init script but not sure what to put…

When I open a PHP file, I’d like to have the code automatically folded (editor:fold-all)

Any suggestions?

It needs to be on newly opened files only and ideally just on files with a .php extension



Something like this should do:

atom.workspace.onDidAddTextEditor ({textEditor}) ->
  if textEditor.getGrammar().scopeName is 'text.html.php'
    atom.commands.dispatch(atom.views.getView(textEditor), 'editor:fold-all')


Cheers. Works a treat…