2022-01-04

Enhance your notes with Snippets and Emoji

Default Layout

Vim-notes is absolutely unmissable if you are an avid note-taker as I am, and you use VIM for almost anything. One option I find particularly useful is the possibility to define a custom default note layout. I can set the global variable g:notes_shadowdir to a directory anywhere in my file-system and inside a New Note text file (without suffix) that will be used as the default note.

Wintermnote uses a similar approach, the path to a text file in the configuration can be set to fill an empty note (relative to %UserProfile%). This file can be a fixed one or it can be regenerated at regular intervals with a scheduled task. If left empty a new note will have the layout shown below.

A set of tags are self-generated from the note's title together with the creation date.

Vim Snippets

To generate a recurring block of text I use a snippets manager (vim-snipmate). Vim-notes defines a specific Vim filetype (notes) for its buffers, thus it's possible to have a dedicated snippets file just for your notes.

To enable the snippets for this filetype, I have included the following configuration in my .vimrc.

    let g:snipMate = { 'snippet_version' : 1 }
    let g:snipMate.scope_aliases = {}
    let g:snipMate.scope_aliases.txt = 'notes'
    imap <M-m> <Plug>snipMateNextOrTrigger
    smap <M-m> <Plug>snipMateNextOrTrigger
    

It's also advisable to avoid the @ character in the snippet's name, it can interfere with tags completion. To achieve self-completion selection while typing we can install the COC-plugin with the command:

   :CocInstall coc-snippets

Emojis

Emojis inside a note can also save typing without loss of clarity. It's also possible to add the emojis plugin as described previously with the command:

   :CocInstall coc-emoji

The emoji plugin can be only enabled for markdown files, see my dotfiles repository - vimfiles subdirectory - coc-settings.json.