From e27f533cc3e91020e36ed77cde5e7652c2bb1c99 Mon Sep 17 00:00:00 2001 From: ethanmuller Date: Thu, 14 Feb 2013 14:18:18 -0500 Subject: [PATCH 1/3] Let ScratchBufferOpen() accept a vertical split option --- plugin/scratch.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/scratch.vim b/plugin/scratch.vim index 05b9018..86c747a 100644 --- a/plugin/scratch.vim +++ b/plugin/scratch.vim @@ -53,7 +53,7 @@ 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 " If the current buffer is modified then open the scratch buffer in a new @@ -104,7 +104,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) From bab530b64d1c258e5bc048be27612fa70e68ed0c Mon Sep 17 00:00:00 2001 From: ethanmuller Date: Thu, 14 Feb 2013 14:22:51 -0500 Subject: [PATCH 2/3] Add paths for vertical_split --- plugin/scratch.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/scratch.vim b/plugin/scratch.vim index 86c747a..1c938a8 100644 --- a/plugin/scratch.vim +++ b/plugin/scratch.vim @@ -55,6 +55,7 @@ let ScratchBufferName = "__Scratch__" " Open the scratch buffer 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,vertical_split) 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,vertical_split) 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 From 36f34405399f57826aa7795f13ed43644895c1cf Mon Sep 17 00:00:00 2001 From: ethanmuller Date: Thu, 14 Feb 2013 14:24:37 -0500 Subject: [PATCH 3/3] Update README to include :Vscratch command --- README | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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.