" define function to turn current buffer into a scratch buffer
function! s:Scratch()
  setlocal buftype=nofile bufhidden=hide noswapfile
endfunction

" define commands to open scratch buffers with Scratch()
command! -nargs=0 Scratch enew | call s:Scratch()
command! -nargs=0 SScratch split | Scratch
command! -nargs=0 VScratch vsplit | Scratch
command! -nargs=0 TScratch tabnew | Scratch

" define function to turn current buffer into a scratch buffer
function! s:Scratch(...)
  setlocal buftype=nofile bufhidden=hide noswapfile

  if exists('a:1')
    execute 'set filetype=' . a:1
  endif
endfunction

" define commands to open scratch buffers with Scratch()
command! -nargs=? -complete=filetype Scratch enew | call s:Scratch(<q-args>)
command! -nargs=? -complete=filetype SScratch split | Scratch <args>
command! -nargs=? -complete=filetype VScratch vsplit | Scratch <args>
command! -nargs=? -complete=filetype TScratch tabnew | Scratch <args>

Allow passing filetype to :Scratch
Allow passing filetype to :Scratch

For convenience, :Scratch now takes a single optional filetype argument.
This filetype will be applied to the scratch buffer. For example,
:Scratch json will open a JSON scratch buffer.

This applies to all :Scratch variants, e.g. :SScratch.

The argument to :Scratch is Tab-completable, for convenience.

igemnace/vim-config,igemnace/vim-config,igemnace/my-vim-config,igemnace/vim-config