init
This commit is contained in:
7
my_snippets/all.snippets
Normal file
7
my_snippets/all.snippets
Normal file
@@ -0,0 +1,7 @@
|
||||
snippet "(?<!\w)ltx" "LaTeX symbol" r
|
||||
LaTeX
|
||||
endsnippet
|
||||
|
||||
snippet arw "Right-pointed arrow"
|
||||
--> $1
|
||||
endsnippet
|
||||
149
my_snippets/cpp.snippets
Normal file
149
my_snippets/cpp.snippets
Normal file
@@ -0,0 +1,149 @@
|
||||
snippet bar "barebone code template"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <stack>
|
||||
#include <queue>
|
||||
#include <numeric>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet icd "#include directive" b
|
||||
#include <$1>
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet plist "print vector" w
|
||||
template <class T>
|
||||
void printList(const T& arr, const string& desc) {
|
||||
std::cout << desc << ": [";
|
||||
for (auto it = arr.begin(); it != arr.end(); it++) {
|
||||
std::cout << *it << ((std::next(it) != arr.end()) ? ", " : "");
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pmat "print matrix" w
|
||||
template <class T>
|
||||
void printMat(const std::vector<std::vector<T>>& mat, const string& desc) {
|
||||
std::cout << desc << ": " << std::endl;
|
||||
for (auto it1 = mat.begin(); it1 != mat.end(); it1++) {
|
||||
auto cur_vec = *it1;
|
||||
std::cout << "[";
|
||||
for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++) {
|
||||
std::cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pqueue "print queue"
|
||||
template <class T>
|
||||
void printQueue(T q) {
|
||||
while (!q.empty()) {
|
||||
std::cout << q.top() << " ";
|
||||
q.pop();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet cout "print a variable" w
|
||||
std::cout << "$1: " << $2 << std::endl;
|
||||
endsnippet
|
||||
|
||||
snippet random "Generate a random list" b
|
||||
std::vector<int> genRandom(int low, int high, int len) {
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int> distribution(low, high);
|
||||
|
||||
std::vector<int> arr(len, 0);
|
||||
for (int i = 0; i != len; ++i) {
|
||||
arr[i] = distribution(gen);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet incset "Use set" b
|
||||
#include <set>
|
||||
endsnippet
|
||||
|
||||
snippet incmap "Use map" b
|
||||
#include <map>
|
||||
endsnippet
|
||||
|
||||
snippet incqueue "Use queue" b
|
||||
#include <queue>
|
||||
endsnippet
|
||||
|
||||
snippet incstr "Use string" b
|
||||
#include <string>
|
||||
endsnippet
|
||||
|
||||
snippet incvec "Use vector" b
|
||||
#include <vector>
|
||||
endsnippet
|
||||
|
||||
snippet incstack "Use stack" b
|
||||
#include <stack>
|
||||
endsnippet
|
||||
|
||||
snippet vec "std::vector" w
|
||||
std::vector<$1> ${2:vec}
|
||||
endsnippet
|
||||
|
||||
snippet map "std::map" w
|
||||
std::map<$1, $2> ${3:mymap}
|
||||
endsnippet
|
||||
|
||||
snippet umap "std::unordered_map"
|
||||
std::unordered_map<$1, $2> ${3:mymap}
|
||||
endsnippet
|
||||
|
||||
snippet set "std::set" w
|
||||
std::set<$1> ${2:myset}
|
||||
endsnippet
|
||||
|
||||
snippet uset "std::unordered_set" w
|
||||
std::unordered_set<$1> ${2:myset}
|
||||
endsnippet
|
||||
|
||||
snippet queue "std::queue" w
|
||||
std::queue<$1> ${2:q}
|
||||
endsnippet
|
||||
|
||||
snippet stack "std::stack" w
|
||||
std::stack<$1> ${2:mystack}
|
||||
endsnippet
|
||||
|
||||
snippet for "for loop" w
|
||||
for ($1; $2; $3) {
|
||||
$4
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet if "if condition" w
|
||||
if ($1) {
|
||||
$2
|
||||
}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ifelse "if else condition"
|
||||
if ($1) {
|
||||
$2
|
||||
} else {
|
||||
|
||||
}
|
||||
endsnippet
|
||||
163
my_snippets/markdown.snippets
Normal file
163
my_snippets/markdown.snippets
Normal file
@@ -0,0 +1,163 @@
|
||||
global !p
|
||||
def gen_header(snip):
|
||||
placeholders_string = snip.buffer[snip.line].strip()
|
||||
level = int(placeholders_string[0])
|
||||
|
||||
# erase current line
|
||||
snip.buffer[snip.line] = ""
|
||||
line_content = "#" * level + " ${1:Section Name}"
|
||||
line_content += '\n$0'
|
||||
|
||||
snip.expand_anon(line_content)
|
||||
endglobal
|
||||
|
||||
snippet "(k1|kbd)" "HTML kbd tag" rw
|
||||
<kbd>${1:KEY}</kbd>$0
|
||||
endsnippet
|
||||
|
||||
snippet k2 "Two key strokes shortcut"
|
||||
<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd>
|
||||
endsnippet
|
||||
|
||||
snippet k3 "Three key strokes shortcut"
|
||||
<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd> + <kbd>${3:KEY}</kbd>
|
||||
endsnippet
|
||||
|
||||
snippet meta "Markdown front matter (YAML format)" b
|
||||
---
|
||||
title: "$1"
|
||||
date: `!p from datetime import datetime
|
||||
if not snip.c:
|
||||
snip.rv = datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S%z")`
|
||||
tags: [$2]
|
||||
categories: [$3]
|
||||
---
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet more "HTML more tag"
|
||||
<!--more-->
|
||||
endsnippet
|
||||
|
||||
snippet img "Aligned image using HTML tag"
|
||||
<p align="center">
|
||||
<img src="${1:URL}" width="${2:800}">
|
||||
</p>
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet font "HTML font tag"
|
||||
<font color="${1:blue}">${2:TEXT}</font>
|
||||
endsnippet
|
||||
|
||||
snippet link "Markdown links"
|
||||
[$1]($2)$0
|
||||
endsnippet
|
||||
|
||||
snippet rlink "Markdown ref link"
|
||||
[${1:link_text}][${2:label}]
|
||||
endsnippet
|
||||
|
||||
post_jump "gen_header(snip)"
|
||||
snippet "h([1-6])" "Markdown header" br
|
||||
`!p snip.rv = match.group(1)`
|
||||
endsnippet
|
||||
|
||||
snippet detail "Clickable details" b
|
||||
<details>
|
||||
<summary><font size="2" color="red">${1:Click to show the code.}</font></summary>
|
||||
|
||||
$2
|
||||
</details>
|
||||
|
||||
snippet info "info box"
|
||||
<style type="text/css">
|
||||
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||
|
||||
.info-msg {
|
||||
color: #059;
|
||||
background-color: #BEF;
|
||||
margin: 5px 0;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
border: 2px solid transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="info-msg">
|
||||
<i class="fa fa-info-circle"> Info</i></br>
|
||||
${1:info text}
|
||||
</div>
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet warn "warning box"
|
||||
<style type="text/css">
|
||||
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||
|
||||
.warning-msg {
|
||||
color: #9F6000;
|
||||
background-color: #FEEFB3;
|
||||
margin: 5px 0;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
border: 2px solid transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="warning-msg">
|
||||
<i class="fa fa-warning"> Warning</i></br>
|
||||
${1:warning text}
|
||||
</div>
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet error "error box"
|
||||
<style type="text/css">
|
||||
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||
|
||||
.error-msg {
|
||||
color: #D8000C;
|
||||
background-color: #FFBABA;
|
||||
margin: 5px 0;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
border: 2px solid transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
<style>
|
||||
|
||||
<div class="error-msg">
|
||||
<i class="fa fa-times-circle"> Error</i></br>
|
||||
${1:error text}
|
||||
</div>
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet success "success box"
|
||||
<style type="text/css">
|
||||
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||
|
||||
.success-msg {
|
||||
color: #270;
|
||||
background-color: #DFF2BF;
|
||||
margin: 5px 0;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
border: 2px solid transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="success-msg">
|
||||
<i class="fa fa-check"></i>
|
||||
${1:success text}
|
||||
</div>
|
||||
$0
|
||||
endsnippet
|
||||
15
my_snippets/python.snippets
Normal file
15
my_snippets/python.snippets
Normal file
@@ -0,0 +1,15 @@
|
||||
snippet fimp "from foo import bar"
|
||||
from ${1:foo} import ${2:bar}
|
||||
endsnippet
|
||||
|
||||
snippet impa "import foo as bar"
|
||||
import ${1:foo} as ${2:bar}
|
||||
endsnippet
|
||||
|
||||
snippet main "Main function boilerplate" b
|
||||
def main():
|
||||
$0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
endsnippet
|
||||
5
my_snippets/snippets.snippets
Normal file
5
my_snippets/snippets.snippets
Normal file
@@ -0,0 +1,5 @@
|
||||
snippet snip "Ultisnips snippet definition" b
|
||||
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
|
||||
${0:${VISUAL}}
|
||||
`!p snip.rv = "endsnippet"`
|
||||
endsnippet
|
||||
9
my_snippets/tex.snippets
Normal file
9
my_snippets/tex.snippets
Normal file
@@ -0,0 +1,9 @@
|
||||
snippet use "usepackage" b
|
||||
\usepackage{${1:package}}
|
||||
endsnippet
|
||||
|
||||
snippet eqa "equation environment" b
|
||||
\begin{equation}\label{$1}
|
||||
$2
|
||||
\end{equation}
|
||||
endsnippet
|
||||
14
my_snippets/vim.snippets
Normal file
14
my_snippets/vim.snippets
Normal file
@@ -0,0 +1,14 @@
|
||||
snippet fun "vim function"
|
||||
function! ${1:MyFunc}(${2}) abort
|
||||
$3
|
||||
endfunction
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet aug "vim augroup" b
|
||||
augroup ${1:GROUP_NAME}
|
||||
autocmd!
|
||||
autocmd ${2:EVENT} ${3:PATTERN} $4
|
||||
augroup END
|
||||
$0
|
||||
endsnippet
|
||||
Reference in New Issue
Block a user