Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes it is the right place to ask questions. </p> <p>The way canopy allows you to do this and a lot of other customizations like that is by using the macro recorder. With canopy open, select Tools > Record macro. Type a name for that macro, something like <code>new_file_with_header</code>. Then click in the code editor, and <code>ctrl-n</code> or <code>cmd-n</code> to create a new file and type whatever you want at the top. Then, tools > stop macro recording and then Tools > edit macro. You should find the new one you created and double-clicking on it should show you the code that it will run if you execute it. I did it with just writing <code># Hello world</code> and got:</p> <pre><code># -*- coding: utf-8 -*- def run(): code_task = get_active_task() code_task.new_file(factory_id='canopy.editor.code_editor', editor_type='Python') code_editor = code_task.active_editor cursor = code_editor.cursor cursor.write(u'# Hello world') code_editor.autoindent_newline() </code></pre> <p>The good news is that this is plain python, so if you wanted to add the date of today, you can modify it similar to that:</p> <pre><code># -*- coding: utf-8 -*- import datetime def run(): code_task = get_active_task() code_task.new_file(factory_id='canopy.editor.code_editor', editor_type='Python') code_editor = code_task.active_editor cursor = code_editor.cursor cursor.write(u'# Hello world %s' % datetime.datetime.now().strftime("%H-%M-%S")) code_editor.autoindent_newline() </code></pre> <p>Ultimately, assign a keybinding that is not already in use and off you go.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload