From 307dcac31ed317b9f8439bcb766fa599e6c4efa7 Mon Sep 17 00:00:00 2001 From: Joey Shi Date: Sun, 30 Oct 2022 23:29:28 -0700 Subject: very cool vimscript --- entries/joeyshi12/vimscript/fib.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 entries/joeyshi12/vimscript/fib.vim (limited to 'entries') diff --git a/entries/joeyshi12/vimscript/fib.vim b/entries/joeyshi12/vimscript/fib.vim new file mode 100644 index 0000000..b385049 --- /dev/null +++ b/entries/joeyshi12/vimscript/fib.vim @@ -0,0 +1,28 @@ +" Add me to your .vimrc :] + +function! Fib(n) + if a:n == 0 + return "0" + elseif a:n == 1 + return "0,1" + endif + let sequence = "0,1" + let prev = 0 + let curr = 1 + let iter = 2 + while iter <= a:n + let curr = prev + curr + let prev = curr - prev + let sequence .= "," . curr + let iter += 1 + endwhile + return sequence +endfunction + +function! AppendFib(n) + execute "normal! i" . Fib(a:n) . "\" +endfunction + +" Map AppendFib to \fib +:command! -nargs=1 AppendFib :call AppendFib() +nnoremap fib :AppendFib -- cgit v1.2.3-70-g09d2 From bd48b2fd67e96cf24ded63775f1bb6e00db9491e Mon Sep 17 00:00:00 2001 From: Joey Shi Date: Sun, 30 Oct 2022 23:36:37 -0700 Subject: added demo.gif --- entries/joeyshi12/vimscript/demo.gif | Bin 0 -> 7095776 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 entries/joeyshi12/vimscript/demo.gif (limited to 'entries') diff --git a/entries/joeyshi12/vimscript/demo.gif b/entries/joeyshi12/vimscript/demo.gif new file mode 100644 index 0000000..9c5efe9 Binary files /dev/null and b/entries/joeyshi12/vimscript/demo.gif differ -- cgit v1.2.3-70-g09d2 From 492347586ddf0244fdbe0d68e3935825771611f5 Mon Sep 17 00:00:00 2001 From: Joey Shi Date: Sun, 30 Oct 2022 23:38:33 -0700 Subject: removed gif --- entries/joeyshi12/vimscript/demo.gif | Bin 7095776 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 entries/joeyshi12/vimscript/demo.gif (limited to 'entries') diff --git a/entries/joeyshi12/vimscript/demo.gif b/entries/joeyshi12/vimscript/demo.gif deleted file mode 100644 index 9c5efe9..0000000 Binary files a/entries/joeyshi12/vimscript/demo.gif and /dev/null differ -- cgit v1.2.3-70-g09d2