Skip to content

Creating Note Templates

Max Bigras edited this page May 5, 2016 · 1 revision

Note Templates

Creating notes with templates

The command to create a new note is

new_evernote_note

by default the command will create a new note with the following meta information

---
title:  
notebook: 
tags: 
---

The meta information can be filled out and navigated just like sublime's snippets. That is, by entering text and then tabbing through to different areas of interest. In sublime we call the files that describe this "template-like" behavior snippets, while in sublime-evernote we just call them "templates". We can use sublime-evernote's templates to make repetitive note creation easier.

There are some key points to take note of when creating templates:

  1. Templates are stored in files with the extension .md, unlike snippets, which are stored in files with the extension .sublime-snippet
  2. The structure of a template file is different than a snippet file
  3. There are at least two different ways to let your template files talk to the new_evernote_note command and sublime-evernote's behavior can be very different depending on which route you choose.
  4. For templates the naming convention you choose to adopt can matter and affects whether or not you are able to generate a quick panel of the templates you've created
  5. Templates are files that give sublime-evernote a template with which to create a new note and are inserted when the note is created, conversely snippets are usually activated with a "tabtrigger", a keyword (followed by pressing tab) that tells Sublime that you want to insert a snippet into the editor.

Creating effective templates

You can get the templates you create talk to the new_evernote_note command in 2 different places:

  1. In your Evernote.sublime-settings file by adjusting the value of default_template
  2. In your Default (OSX).sublime-keymap file by adding a keymap and passing a template argument to the new_evernote_note command

Now, of the 2 different places you can talk to the new_evernote_note command there are also 2 different ways to reference templates:

  1. a full path like Packages/User/evernote/documentation/example_evernote_template.md
  2. a filename pattern like evernote_*.md

It is through using option 2 that we are able to get sublime-evernote to generate a quick panel of available templates to choose from. The important thing to be aware of is the filename pattern must create a conflict so sublime-evernote doesn't know which template to choose, but you also need to keep in mind that your filename pattern must be specific enough so you aren't referencing any old .md file that happens to floating around in your Packages directory. You can achieve this by being choosing the name your templates effectively and referencing them accurately. When using a filename pattern it's important to realize that sublime-evernote parses through your entire Packages directory, and so you should not mix option 1 and 2 together and try to reference your templates like this: Packages/User/evernote/documentation/evernote_*.md

Example

If you have the following templates:

~/Library/Application Support/Sublime Text 3/Packages/User/evernote/documentation ls
evernote_empty_template.md        Just_A_Regular_Markdown_File.md
evernote_image_template.md        custom_default_template.md
evernote_quick_bullet_template.md

and you wanted a quick panel of all your Evernote templates to choose from when you use hit the super+e, super+t key combination then you could add the following entry to your Default (OSX).sublime-keymap:

// To have choice of templates
{ "keys": ["super+e", "super+t"], "command": "new_evernote_note", "args": {"template": "evernote_*.md"}},

Now super+e, super+t will bring up a quick panel to choose from your three specially named, specially referenced sublime-evernote templates that give you super awesome snippet-like functionality, while avoiding all your other markdown files such as Just_A_Regular_Markdown_File.md

Another Example

What if for the same give file structure you decide that you'd like your default note creation template to look like the following:

---
title: ${2: Some title}
notebook: $1 
tags:
---
# ${2: Some heading}
$3

Because maybe you don't like tags, and you want a large heading within the note body to be the same as the note title. You could achieve this using sublime-evernote's templates. Save the above code into a file named custom_default_template.md and place it in the Packages/User/evernote/documentation/ directory (it could be anywhere in Packages but let's keep it here just to stay organized). Now we can modify the default template of the new_evernote_note command by placing the following line in our Evernote.sublime-settings file:

"default_template": "Packages/User/evernote/documentation/custom_default_template.md",
Clone this wiki locally