aboutsummaryrefslogtreecommitdiff
path: root/autoload/scratch_buffer.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-07-24 12:19:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-07-24 12:19:47 +1200
commit8838fdab0d005189e0f562e4689ad7e05e8f9997 (patch)
tree6e012ba2b36d3b841ba2d3283e5863ed14be1995 /autoload/scratch_buffer.vim
parentCommit plugin as it stands (diff)
downloadvim-scratch-buffer-8838fdab0d005189e0f562e4689ad7e05e8f9997.tar.gz
vim-scratch-buffer-8838fdab0d005189e0f562e4689ad7e05e8f9997.zip
Add spacing and commentary to code
Diffstat (limited to 'autoload/scratch_buffer.vim')
-rw-r--r--autoload/scratch_buffer.vim19
1 files changed, 18 insertions, 1 deletions
diff --git a/autoload/scratch_buffer.vim b/autoload/scratch_buffer.vim
index c0ef7cf..4051fa5 100644
--- a/autoload/scratch_buffer.vim
+++ b/autoload/scratch_buffer.vim
@@ -1,11 +1,28 @@
+" Entry point for :ScratchBuffer command
function! scratch_buffer#(mods, count, ...) abort
+
+ " Start building command argument vector
let command = []
+
+ " Add any modifiers first (e.g. :vertical)
call add(command, a:mods)
- if a:count
+
+ " If a count of more than zero was provided, add that as a prefix for :new
+ if a:count > 0
call add(command, a:count)
endif
+
+ " Add the :new command
call add(command, 'new')
+
+ " Add any other arguments passed in
call extend(command, a:000)
+
+ " Execute the command
execute join(command)
+
+ " Set the new buffer to a scratch 'buftype' to stop it from saving and to
+ " reassure Vim that it doesn't need to be saved
set buftype=nofile
+
endfunction