Is there a package or a way to put a default code in a new file on atom?
Yes, but you’ll need to describe what you want in more detail. I don’t know of a specific package, but it’s a pretty easy
Would be awesome if you could show how to add
# -*- coding: utf-8 -*- to the beginning of every new file.
That’s awfully broad. Are you sure you’re literally never going to be making a file that isn’t Python? You could write a snippet with the
#c that expands into that line.
Thanks. I build the snippet like the manual said. How can I set it to be excecuted every time I create a new python file?
You don’t. That’s not what snippets are for. You can add code to your
init.coffee to automatically add text to a new file, but first I need to be absolutely sure I know what you want to do, hence my question earlier. Do you want any blank Python file to get encoding information added to it?
Yes, exactly. Any blank Python file should contain this header. Thanks!
Add this to your
atom.workspace.observeTextEditors (editor) -> python = atom.grammars.grammarForScopeName "source.python" if editor.isEmpty() and editor.getGrammar() == python editor.insertText "# -*- coding: utf-8 -*-"