Skip to content

Instantly share code, notes, and snippets.

@dphase dphase/functions.vim

Created Feb 20, 2020
Embed
What would you like to do?
" 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
You can’t perform that action at this time.