~gpanders/dotfiles

ref: 466bbcb447b26f0f86b41d8d2834277f36764a2a dotfiles/.vim/plugin/journal.vim -rw-r--r-- 760 bytes
466bbcb4 — Gregory Anders fish: allow multiple venvs to be removed at once a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
" Command to easily open journal
if exists('g:loaded_journal') || empty($JOURNAL_FILE)
    finish
endif
let g:loaded_journal = 1

function! s:entry()
    let date = strftime('%a, %d %b, %Y')
    if !search(date, '')
        let lines = [date, repeat('=', len(date)), '', '', '']
        call append(0, lines)
        call cursor(len(lines) - 1, 1)
    endif
endfunction

augroup journal
    autocmd!
    autocmd BufRead $JOURNAL_FILE call s:entry()
    autocmd BufWinEnter $JOURNAL_FILE setlocal foldlevel=0
    autocmd BufWinEnter $JOURNAL_FILE let w:view = winsaveview() |
                \ normal! 1Gzo |
                \ call winrestview(w:view) |
                \ unlet w:view
augroup END

command! -nargs=0 Journal edit +set\ ft=markdown $JOURNAL_FILE