commit b4b73b3d4347e89e48d8f86aab645ae9c6d81a2d
parent 88c04cb06a432d701b6cbee91e3312c7c78fdc8e
Author: Chris Bracken <chris@bracken.jp>
Date: Tue, 20 Apr 2021 14:54:48 -0700
Add a simple, manual snippets system
Allows for simple injection of code snippets in common cases.
Diffstat:
6 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/.vim/snippets/cc.cc b/.vim/snippets/cc.cc
@@ -0,0 +1,9 @@
+#include "cc.h"
+
+namespace foo {
+
+Bar::Bar() {}
+
+Bar::~Bar() {}
+
+} // namespace foo
diff --git a/.vim/snippets/cc.h b/.vim/snippets/cc.h
@@ -0,0 +1,17 @@
+#ifndef _H_
+#define _H_
+
+namespace foo {
+
+class Bar {
+ public:
+ Bar();
+ ~Bar();
+
+ private:
+ int baz_;
+};
+
+} // namespace foo
+
+#endif // _H_
diff --git a/.vim/snippets/class.cc b/.vim/snippets/class.cc
@@ -0,0 +1,8 @@
+class Bar {
+ public:
+ Bar();
+ ~Bar();
+
+ private:
+ int baz_;
+};
diff --git a/.vim/snippets/namespace.cc b/.vim/snippets/namespace.cc
@@ -0,0 +1,2 @@
+namespace foo {
+} // namespace foo
diff --git a/.vim/snippets/struct.cc b/.vim/snippets/struct.cc
@@ -0,0 +1,2 @@
+struct Bar {
+};
diff --git a/.vim/vimrc b/.vim/vimrc
@@ -138,6 +138,13 @@ nmap <leader>kn 3<Plug>VimwikiMakeDiaryNote
au FileType vimwiki nmap <leader>dp <Plug>VimwikiDiaryPrevDay
au FileType vimwiki nmap <leader>dn <Plug>VimwikiDiaryNextDay
+" Snippets
+nmap <leader>sch :0r ~/.vim/snippets/cc.h<CR>
+nmap <leader>sci :0r ~/.vim/snippets/cc.cc<CR>
+nmap <leader>scn :.-1r ~/.vim/snippets/namespace.cc<CR>
+nmap <leader>scs :.-1r ~/.vim/snippets/struct.cc<CR>
+nmap <leader>scc :.-1r ~/.vim/snippets/class.cc<CR>
+
" Configure colour scheme and syntax highlighting.
if &t_Co > 2
syntax enable