Automatically run commands on opening a file


#1

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

TIA


#2

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')

#3

Cheers. Works a treat…