summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2025-08-04 01:32:04 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2025-08-04 01:32:04 +0200
commit3189c372859c6c807dc86aa8782bacaa3c2826c1 (patch)
tree4e50940e070a777b0ed8228ee81564f83aeddcc4 /autoload
downloadsniper.vim-3189c372859c6c807dc86aa8782bacaa3c2826c1.tar.gz
Engage!
Diffstat (limited to 'autoload')
-rw-r--r--autoload/sniper.vim43
1 files changed, 43 insertions, 0 deletions
diff --git a/autoload/sniper.vim b/autoload/sniper.vim
new file mode 100644
index 0000000..6d364d6
--- /dev/null
+++ b/autoload/sniper.vim
@@ -0,0 +1,43 @@
+let s:buffer_store = ['', '', '', '']
+
+function! sniper#StoreBuffer(pos) abort
+ if a:pos < 1 || a:pos > 4
+ echoerr "Position must be between 1-4"
+ return
+ endif
+ let s:buffer_store[a:pos - 1] = bufnr('%')
+ echo "Stored buffer" bufnr('%') "in position" a:pos
+endfunction
+
+function! sniper#RecallBuffer(pos) abort
+ if a:pos < 1 || a:pos > 4
+ echoerr "Position must be between 1-4"
+ return
+ endif
+
+ let target_buf = s:buffer_store[a:pos - 1]
+ if empty(target_buf) || !bufexists(target_buf)
+ echo "No buffer stored in position" a:pos
+ return
+ endif
+
+ execute "buffer" target_buf
+endfunction
+
+function! sniper#ListBuffers() abort
+ let output = ["Buffer list:", ""]
+ for i in range(4)
+ let bufnum = s:buffer_store[i]
+ if !empty(bufnum) && bufexists(bufnum)
+ let status = printf("[F%d] %s (%s) - %s",
+ \ i+1,
+ \ bufname(bufnum),
+ \ bufnum,
+ \ buflisted(bufnum) ? "LOADED" : "UNLOADED")
+ else
+ let status = printf("[F%d] <empty>", i+1)
+ endif
+ call add(output, status)
+ endfor
+ echo join(output, "\n")
+endfunction