aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraxton Hall2022-10-31 06:52:18 +0000
committerGitHub2022-10-31 06:52:18 +0000
commitb19e171b583785feb3bc74cacd5be2f238bfef30 (patch)
treef6cf04b18dd852fea3b4bcd1740284dd486e6f19
parent6f19316d1f4213771cde72ca2fb17c4f8bd4b9f5 (diff)
parent492347586ddf0244fdbe0d68e3935825771611f5 (diff)
Merge pull request #75 from joeyshi12/main
Add vimscript
-rw-r--r--entries/joeyshi12/vimscript/fib.vim28
-rw-r--r--people.json13
2 files changed, 40 insertions, 1 deletions
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) . "\<Esc>"
+endfunction
+
+" Map AppendFib to \fib
+:command! -nargs=1 AppendFib :call AppendFib(<q-args>)
+nnoremap <Leader>fib :AppendFib<Space>
diff --git a/people.json b/people.json
index 990e755..155858b 100644
--- a/people.json
+++ b/people.json
@@ -608,5 +608,16 @@
"link": "./entries/timstr/fib.cpp"
}
]
- }
+ },
+ {
+ "github": "joeyshi12",
+ "name": "Joey Shi",
+ "title": "BSc, UBC",
+ "entries": [
+ {
+ "name": "vimscript",
+ "link": "./entries/joeyshi12/vimscript/fib.vim"
+ }
+ ]
+ }
]