Skip to content

Instantly share code, notes, and snippets.

@dphase
Created February 20, 2020 17:09
Show Gist options
  • Save dphase/1792d67b4ac06aea11a49ed801f18a7e to your computer and use it in GitHub Desktop.
Save dphase/1792d67b4ac06aea11a49ed801f18a7e to your computer and use it in GitHub Desktop.
" 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