Skip to content

Commit

Permalink
🌟feature(nvim): convert snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
cutbypham committed Oct 25, 2021
1 parent 89b4cd6 commit 9b2173b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 79 deletions.
112 changes: 52 additions & 60 deletions nvim/coq-user-snippets/cpp.snippets
Original file line number Diff line number Diff line change
@@ -1,84 +1,76 @@
snippet if
if ( $1 ) {
$2
}
endsnippet
if ( $1 ) {
$2
}

snippet for
for (int ${1:i} = 0; $1 < ${2:n}; $1++) {
$0
}
endsnippet
for (int ${1:i} = 0; $1 < ${2:n}; $1++) {
$0
}

snippet do
do {
1;
} while ($2);
endsnippet
do {
1;
} while ($2);

snippet while
while ($1) {
$2;
}
endsnippet
while ($1) {
$2;
}

snippet main
#include <iostream>
using namespace std;
using namespace std;

int main() {
return 0;
}
endsnippet
int main() {
return 0;
}

snippet kiemTraSoNguyenTo
bool kiemTraSoNguyenTo(int number) {
bool flag = false;
int count = 0;
bool kiemTraSoNguyenTo(int number) {
bool flag = false;
int count = 0;

if (number < 2 || number > 100) {
flag = false;
} else {
for (int i = 2; i <= number / 2; i++) {
if (number % i == 0) {
count++;
if (number < 2 || number > 100) {
flag = false;
} else {
for (int i = 2; i <= number / 2; i++) {
if (number % i == 0) {
count++;
}
}
if (count == 0) {
flag = true;
}
}
return flag;
}
if (count == 0) {
flag = true;
}
}
return flag;
}
endsnippet

snippet nhapSoNguyenDuong
int nhapSoNguyenDuong(int &n) {
do {
cin >> n;
} while (n <= 0);
int nhapSoNguyenDuong(int &n) {
do {
cin >> n;
} while (n <= 0);

return n;
}
endsnippet
return n;
}

snippet kiemTraSoHoangThien
bool kiemTraSoHoangThien(int number) {
int sum = 0;
int flag = false;
bool kiemTraSoHoangThien(int number) {
int sum = 0;
int flag = false;

for (int i = 1; i < number; i++) {
if (number % i == 0) {
sum += i;
}
}
for (int i = 1; i < number; i++) {
if (number % i == 0) {
sum += i;
}
}

if (sum == number) {
flag = true;
} else {
flag = false;
}
if (sum == number) {
flag = true;
} else {
flag = false;
}

return flag;
}
endsnippet
return flag;
}
24 changes: 11 additions & 13 deletions nvim/coq-user-snippets/cs.snippets
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
snippet NhapMang
public static void NhapMang(int[] array, int number) {
for (int i = 0; i < number; i++) {
Console.Write("Nhập phần tử thứ " + (i + 1) + ": ");
array[i] = Convert.ToInt32(Console.ReadLine());
}
}
endsnippet
public static void NhapMang(int[] array, int number) {
for (int i = 0; i < number; i++) {
Console.Write("Nhập phần tử thứ " + (i + 1) + ": ");
array[i] = Convert.ToInt32(Console.ReadLine());
}
}

snippet XuatMang
public static void XuatMang(int[] array, int number) {
for (int i = 0; i < number; i++) {
Console.Write(array[i] + "\t");
}
}
endsnippet
public static void XuatMang(int[] array, int number) {
for (int i = 0; i < number; i++) {
Console.Write(array[i] + "\t");
}
}
10 changes: 4 additions & 6 deletions nvim/coq-user-snippets/javascript.snippets
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
snippet cl
console.log( $1 );
endsnippet
console.log( $1 );

snippet for
for (let i = 0; $1 ; i++) {
$2
}
endsnippet
for (let i = 0; $1 ; i++) {
$2
}

0 comments on commit 9b2173b

Please sign in to comment.