diff --git a/README b/README index b1512dd..17c334c 100644 --- a/README +++ b/README @@ -23,10 +23,14 @@ You can use the following command to open/edit the scratch buffer: :Scratch -To open the scratch buffer in a new split window, use the following command: +To open the scratch buffer in a new horizontal split window, use the following command: :Sscratch +To open the scratch buffer in a new vertical split window, use the following command: + + :Vscratch + When you close the scratch buffer window, the buffer will retain the contents. You can again edit the scratch buffer by openeing it using one of the above commands. There is no need to save the scatch buffer. diff --git a/plugin/scratch.vim b/plugin/scratch.vim index 05b9018..1c938a8 100644 --- a/plugin/scratch.vim +++ b/plugin/scratch.vim @@ -53,8 +53,9 @@ let ScratchBufferName = "__Scratch__" " ScratchBufferOpen " Open the scratch buffer -function! s:ScratchBufferOpen(new_win) +function! s:ScratchBufferOpen(new_win,vertical_split) let split_win = a:new_win + let vertical_split = a:vertical_split " If the current buffer is modified then open the scratch buffer in a new " window @@ -67,7 +68,11 @@ function! s:ScratchBufferOpen(new_win) if scr_bufnum == -1 " open a new scratch buffer if split_win - exe "new " . g:ScratchBufferName + if vertical_split + exe "vnew " . g:ScratchBufferName + else + exe "new " . g:ScratchBufferName + endif else exe "edit " . g:ScratchBufferName endif @@ -84,7 +89,11 @@ function! s:ScratchBufferOpen(new_win) else " Create a new scratch buffer if split_win - exe "split +buffer" . scr_bufnum + if vertical_split + exe "vsplit +buffer" . scr_bufnum + else + exe "split +buffer" . scr_bufnum + endif else exe "buffer " . scr_bufnum endif @@ -104,7 +113,8 @@ endfunction autocmd BufNewFile __Scratch__ call s:ScratchMarkBuffer() " Command to edit the scratch buffer in the current window -command! -nargs=0 Scratch call s:ScratchBufferOpen(0) -" Command to open the scratch buffer in a new split window -command! -nargs=0 Sscratch call s:ScratchBufferOpen(1) - +command! -nargs=0 Scratch call s:ScratchBufferOpen(0,0) +" Command to open the scratch buffer in a new horizontal split window +command! -nargs=0 Sscratch call s:ScratchBufferOpen(1,0) +" Command to open the scratch buffer in a new vertical split window +command! -nargs=0 Vscratch call s:ScratchBufferOpen(1,1)