Created
February 20, 2020 17:09
-
-
Save dphase/1792d67b4ac06aea11a49ed801f18a7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Language Specific scratch buffers with date | |
" --------------------------------------------------------------------------------- | |
function! s:DScratch(scratch_ft) | |
let scratch_dir = '~/Dropbox/scratch/buffers' | |
let scratch_date = strftime('%Y%m%d') | |
let scratch_file = 'scratch-'. scratch_date . '.' . a:scratch_ft | |
let scratch_buf = bufnr(scratch_file) | |
if scratch_buf == -1 | |
exe 'split ' . scratch_dir . '/' . scratch_file | |
if empty(glob(scratch_dir . '/' . scratch_file)) | |
exe ':normal i# Scratch Buffer - ' . scratch_date | |
exe ':normal o' | |
call CommentHeader() | |
exe ':normal o' | |
exe ':normal ^D' | |
exe ':w' | |
endif | |
else | |
exe 'split +buffer' . scratch_buf | |
endif | |
endfunction | |
command! -nargs=1 Scratch call s:DScratch(<f-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment