Frontmatter

I changed the markdown and readinglist templates to a "frontmatter"
format. Hoping to see if I can make my notes more easily processed by
using a pre-defined header.
This commit is contained in:
2024-03-09 19:17:50 -05:00
parent 46237ae49c
commit 529508f7db
3 changed files with 45 additions and 6 deletions

8
.vim/templates/mdfm Normal file
View File

@@ -0,0 +1,8 @@
:insert
---
filename:
filecreated:
fileupdated:
filetags: []
---

16
.vim/templates/rlfm Normal file
View File

@@ -0,0 +1,16 @@
:insert
---
filename:
filecreated:
fileupdated:
filetags: []
booktitle:
bookauthor:
bookstarted:
bookfinished:
---
[Goodreads Link]()
# Highlights / Notes

27
.vimrc
View File

@@ -337,13 +337,26 @@ hi SpellRare cterm=underline ctermbg=black ctermfg=gray
" ---------------------------------------------------------------------------------------------------------------------
" ==> Templates: markdown documents (.md)
"
" autocmd BufNewFile *.md so $HOME/.vim/templates/md
" autocmd BufNewFile *.md %s/filename/\=expand('%:t:r')/g
" autocmd BufNewFile *.md exe "g/^- Created :.*/s//- Created : " .strftime("%Y-%m-%d")
" autocmd BufNewFile *.md exe "normal Go"
" autocmd BufWritePre,filewritepre *.md execute "normal! ma"
" autocmd BufWritePre,filewritepre *.md exe "g/^- Updated :.*/s//- Updated : " .strftime("%Y-%m-%d %H:%M")
" autocmd BufWritePost,filewritepost *.md execute "normal! `a"
autocmd BufNewFile *.md so $HOME/.vim/templates/md
autocmd BufNewFile *.md %s/filename/\=expand('%:t:r')/g
autocmd BufNewFile *.md exe "g/^- Created :.*/s//- Created : " .strftime("%Y-%m-%d")
" ---------------------------------------------------------------------------------------------------------------------
" ==> Templates: markdown documents with frontmatter (.md)
autocmd BufNewFile *.md so $HOME/.vim/templates/mdfm
"autocmd BufNewFile *.md %s/filename:.*/s//filename:\=expand('%:t:r')
"autocmd BufNewFile *.md %s/filename:.*/\='filename: '.expand('%:t:r')
autocmd BufNewFile *.md exe "g/^filename:.*/s//filename: " .expand('%:t:r')
autocmd BufNewFile *.md exe "g/^filecreated:.*/s//filecreated: " .strftime("%Y-%m-%d")
autocmd BufNewFile *.md exe "normal Go"
autocmd BufWritePre,filewritepre *.md execute "normal! ma"
autocmd BufWritePre,filewritepre *.md exe "g/^- Updated :.*/s//- Updated : " .strftime("%Y-%m-%d %H:%M")
autocmd BufWritePre,filewritepre *.md exe "g/^fileupdated:.*/s//fileupdated: " .strftime("%Y-%m-%d %H:%M")
autocmd BufWritePost,filewritepost *.md execute "normal! `a"
" ---------------------------------------------------------------------------------------------------------------------
" ==> Templates: shell scripts (.sh)
@@ -370,10 +383,12 @@ nnoremap ,begend :-1read $HOME/.vim/templates/begend<CR>jA
nnoremap ,sh :0read $HOME/.vim/templates/sh<CR> <bar> :1<CR>dd <bar> :4%s/filename/\=expand('%:t')/g<CR>
" section readinglist header
nnoremap ,rl :0read $HOME/.vim/templates/readinglist<CR> <bar> :1<CR>dd $
"nnoremap ,rl :0read $HOME/.vim/templates/readinglist<CR> <bar> :1<CR>dd $
nnoremap ,rl :0read $HOME/.vim/templates/rlfm<CR> <bar>zR<CR> <bar> :1<CR>dd :%s/^filename:/\="filename: " . expand('%:t:r')/g<CR>
" section markdown file header
nnoremap ,md :0read $HOME/.vim/templates/md<CR> <bar> :1<CR>dd <bar> :%s/filename/\=expand('%:t:r')/g<CR>
"nnoremap ,md :0read $HOME/.vim/templates/md<CR> <bar> :1<CR>dd <bar> :%s/filename/\=expand('%:t:r')/g<CR>
nnoremap ,md :0read $HOME/.vim/templates/mdfm<CR> <bar>zR<CR> <bar> :1<CR>dd :%s/^filename:/\="filename: " . expand('%:t:r')/g<CR>
" ---------------------------------------------------------------------------------------------------------------------
" ==> NetrwTreeListing readonly fix (https://vi.stackexchange.com/a/13012)