Skip to content

Instantly share code, notes, and snippets.

@hayajo
Created July 6, 2011 02:48
Show Gist options
  • Save hayajo/1066442 to your computer and use it in GitHub Desktop.
Save hayajo/1066442 to your computer and use it in GitHub Desktop.
open_junk_file - vim
" Open junk file
" via. http://vim-users.jp/2010/11/hack181/
command! -nargs=0 JunkFile call s:open_junk_file()
function! s:open_junk_file()
if !exists('g:junk_file_basedir')
let g:junk_file_basedir = $HOME . '/.vim_junk'
endif
let l:junk_file_dir = g:junk_file_basedir . strftime('/%Y/%m')
if !isdirectory(l:junk_file_dir)
call mkdir(l:junk_file_dir, 'p')
endif
let l:filename = input('Junk Code: ', l:junk_file_dir . strftime('/%Y-%m-%d-%H%M%S.'))
if l:filename != ''
execute 'edit ' . l:filename
endif
endfunction
let g:junk_file_basedir=$HOME."/doc/junk"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment