diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-04 01:32:04 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-04 01:32:04 +0200 |
| commit | 3189c372859c6c807dc86aa8782bacaa3c2826c1 (patch) | |
| tree | 4e50940e070a777b0ed8228ee81564f83aeddcc4 | |
| download | sniper.vim-3189c372859c6c807dc86aa8782bacaa3c2826c1.tar.gz | |
Engage!
| -rw-r--r-- | LICENSE | 24 | ||||
| -rw-r--r-- | README.md | 23 | ||||
| -rw-r--r-- | autoload/sniper.vim | 43 | ||||
| -rw-r--r-- | doc/sniper.txt | 76 | ||||
| -rw-r--r-- | plugin/sniper.vim | 13 |
5 files changed, 179 insertions, 0 deletions
@@ -0,0 +1,24 @@ +BSD 2-Clause License + +Copyright (c) 2025, Mitja Felicijan <mitja.felicijan@gmail.com> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c036492 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Simple Vim Buffer Bookmark Manager + +Quickly store and recall buffers with F1-F4 keys. + +## Installation + +Using vim-plug: + +```vim +Plug 'mitjafelicijan/sniper.vim' +``` + +## Usage + +- `Shift-F1` to store current buffer in slot 1 +- `Shift-F2` to store current buffer in slot 2 +- `Shift-F3` to store current buffer in slot 3 +- `Shift-F4` to store current buffer in slot 4 +- `F1` to recall buffer from slot 1 +- `F2` to recall buffer from slot 2 +- `F3` to recall buffer from slot 3 +- `F4` to recall buffer from slot 4 +- `F5` or `:SniperList` to view all stored buffers 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 diff --git a/doc/sniper.txt b/doc/sniper.txt new file mode 100644 index 0000000..f686551 --- /dev/null +++ b/doc/sniper.txt @@ -0,0 +1,76 @@ +*sniper.txt* Sniper Plugin + +============================================================================== +CONTENTS *sniper-contents* + +1. Introduction |sniper-intro| +2. Commands |sniper-commands| +3. Mappings |sniper-mappings| +4. Functions |sniper-functions| +5. License |sniper-license| + +============================================================================== +1. INTRODUCTION *sniper-intro* + +The sniper plugin provides quick buffer storage and recall using F1-F4 keys. +It maintains 4 slots for fast buffer switching. + +============================================================================== +2. COMMANDS *sniper-commands* + +:SniperList List all stored buffers with their status + Shows: [Slot] BufferName (ID) - STATUS + +============================================================================== +3. MAPPINGS *sniper-mappings* + +Normal mode mappings: +<Shift-F1> Store current buffer in slot 1 +<Shift-F2> Store current buffer in slot 2 +<Shift-F3> Store current buffer in slot 3 +<Shift-F4> Store current buffer in slot 4 + +<F1> Recall buffer from slot 1 +<F2> Recall buffer from slot 2 +<F3> Recall buffer from slot 3 +<F4> Recall buffer from slot 4 + +<F5> Lists all buffer slots + +============================================================================== +4. FUNCTIONS *sniper-functions* + +sniper#StoreBuffer(pos) Store current buffer in specified position (1-4) +sniper#RecallBuffer(pos) Recall buffer from specified position (1-4) +sniper#ListBuffers() Display all stored buffers + +============================================================================== +5. LICENSE *sniper-license* + +BSD 2-Clause License +Copyright (c) 2025 Mitja Felicijan + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +vim:tw=78:ts=8:ft=help:norl: diff --git a/plugin/sniper.vim b/plugin/sniper.vim new file mode 100644 index 0000000..50e5f96 --- /dev/null +++ b/plugin/sniper.vim @@ -0,0 +1,13 @@ +nnoremap <silent> <S-F1> :call sniper#StoreBuffer(1)<CR> +nnoremap <silent> <S-F2> :call sniper#StoreBuffer(2)<CR> +nnoremap <silent> <S-F3> :call sniper#StoreBuffer(3)<CR> +nnoremap <silent> <S-F4> :call sniper#StoreBuffer(4)<CR> + +nnoremap <silent> <F1> :call sniper#RecallBuffer(1)<CR> +nnoremap <silent> <F2> :call sniper#RecallBuffer(2)<CR> +nnoremap <silent> <F3> :call sniper#RecallBuffer(3)<CR> +nnoremap <silent> <F4> :call sniper#RecallBuffer(4)<CR> + +nnoremap <silent> <F5> :call sniper#ListBuffers()<CR> + +command! SniperList call sniper#ListBuffers() |
