Skip to content

Template Addition #19

@kapilnchauhan77

Description

@kapilnchauhan77

image

Hey, I saw that template addition was not available so I wrote something that will produce the above mentioned result:

function AddTemplate(tmpl_file)
    exe "0read " . a:tmpl_file
    let substDict = {}
    let substDict["date"] = strftime("%Y %b %d %X")
    exe '%s/<<\([^>]*\)>>/\=substDict[submatch(1)]/g'
    set nomodified
    normal G
endfunction
autocmd BufNewFile todo.md call AddTemplate("~/.vim/plugged/vim-bujo/templates/md.skeleton")

The change I think needed is to have it automatically find the template file.

Also my template file (Minor Changes from yours),

  _____ _ __  _ __  _ __
 /_  __/ __ \/ __ \/ __ \
  / / / / / / / / / / / /
 / / / /_/ / /_/ / /_/ /
/_/  \_  _/_  _ /\_  _/

 
 Date:  <<date>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions