diff options
author | 2024-01-06 18:28:24 +0800 | |
---|---|---|
committer | 2024-01-06 18:28:24 +0800 | |
commit | d8054026033e1ff492dee7bf92b35627e62b9979 (patch) | |
tree | 30cb8baa144fd1ca3bcca766422138b5c7b69d90 | |
parent | 6d31cdcd10dfead571c3ab3ae48c161efe4cef16 (diff) | |
download | Pardon-d8054026033e1ff492dee7bf92b35627e62b9979.tar.gz Pardon-d8054026033e1ff492dee7bf92b35627e62b9979.zip |
Update vim scripts in use and my shell scripts.
-rw-r--r-- | README.md | 3 | ||||
-rwxr-xr-x | mypath/compare.sh | 14 | ||||
-rwxr-xr-x | mypath/count.sh | 30 | ||||
-rwxr-xr-x | mypath/dif.sh | 10 | ||||
-rwxr-xr-x | mypath/exe.sh | 24 | ||||
-rwxr-xr-x | mypath/g.sh | 22 | ||||
-rwxr-xr-x | mypath/gitadd.sh | 45 | ||||
-rwxr-xr-x | mypath/gitk.sh | 2 | ||||
-rwxr-xr-x | mypath/md2html.sh | 29 | ||||
-rw-r--r-- | mypath/runjv.c | 39 | ||||
-rwxr-xr-x | mypath/runjv.sh | 17 | ||||
-rw-r--r-- | vim/vimrc | 12 | ||||
-rw-r--r-- | vim/vimrcs/codecmd.vim (renamed from vim/vimrcs/autocmd.vim) | 89 | ||||
-rw-r--r-- | vim/vimrcs/match.vim | 9 | ||||
-rw-r--r-- | vim/vimrcs/myset.vim | 57 | ||||
-rw-r--r-- | vim/vimrcs/plugs.vim | 52 | ||||
-rw-r--r-- | vim/vimrcs/statusline.vim (renamed from vim/vimrcs/fuck.vim) | 2 |
17 files changed, 353 insertions, 103 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fd6798 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,3 @@ | |||
1 | [Pardon?] | ||
2 | |||
3 | 这里是我自己用的一些代码的暂存。 | ||
diff --git a/mypath/compare.sh b/mypath/compare.sh new file mode 100755 index 0000000..2643b42 --- /dev/null +++ b/mypath/compare.sh | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | file1="file1.txt" | ||
4 | file2="file2.txt" | ||
5 | |||
6 | diff_output=$(diff "$file1" "$file2") | ||
7 | |||
8 | if [ -z "$diff_output" ]; then | ||
9 | echo "两个文件完全一致" | ||
10 | else | ||
11 | echo "两个文件不完全一致" | ||
12 | echo "$diff_output" | ||
13 | fi | ||
14 | |||
diff --git a/mypath/count.sh b/mypath/count.sh new file mode 100755 index 0000000..5105b42 --- /dev/null +++ b/mypath/count.sh | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | count_lines() { | ||
4 | local filename=$1 | ||
5 | local sum=0 | ||
6 | local buf | ||
7 | |||
8 | while IFS= read -r buf; do | ||
9 | ((sum++)) | ||
10 | done < "$filename" | ||
11 | |||
12 | echo "$sum" | ||
13 | } | ||
14 | |||
15 | extensions=("c" "tex" "cpp" "py" "h") | ||
16 | sum=0 | ||
17 | |||
18 | for extension in "${extensions[@]}"; do | ||
19 | files=$(find . -type f -name "*.$extension") | ||
20 | for file in $files; do | ||
21 | tmp=$(count_lines "$file") | ||
22 | ((sum+=tmp)) | ||
23 | echo "文件路径: $file" | ||
24 | echo "行数: $tmp" | ||
25 | echo | ||
26 | done | ||
27 | done | ||
28 | |||
29 | echo "总行数: $sum" | ||
30 | |||
diff --git a/mypath/dif.sh b/mypath/dif.sh new file mode 100755 index 0000000..138522e --- /dev/null +++ b/mypath/dif.sh | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/bash | ||
2 | diff_output=$(diff "$1" "$2") | ||
3 | |||
4 | if [ -z "$diff_output" ];then | ||
5 | echo "The two files are totally the same!" | ||
6 | else | ||
7 | echo "There's something different: " | ||
8 | echo "$diff_output" | ||
9 | fi | ||
10 | exit 0 | ||
diff --git a/mypath/exe.sh b/mypath/exe.sh new file mode 100755 index 0000000..0588058 --- /dev/null +++ b/mypath/exe.sh | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # 检查参数个数 | ||
4 | if [ $# -ne 1 ]; then | ||
5 | echo "参数个数错误!" | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | if [ $1 == "run" ]; then | ||
10 | for file in *.sh; do | ||
11 | filename="${file%.*}" | ||
12 | ln -s "$file" "$filename" | ||
13 | done | ||
14 | echo "软链接创建完成!" | ||
15 | elif [ $1 == "del" ];then | ||
16 | for file in *.sh; do | ||
17 | filename="${file%.*}" | ||
18 | rm -f "$filename" | ||
19 | done | ||
20 | echo "软链接删除成功!" | ||
21 | else | ||
22 | echo "参数错误!" | ||
23 | exit 1 | ||
24 | fi | ||
diff --git a/mypath/g.sh b/mypath/g.sh new file mode 100755 index 0000000..27a1bc0 --- /dev/null +++ b/mypath/g.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # 检查参数数量,小于一报错 | ||
4 | # if [ $# -e 0 ]; then | ||
5 | # echo "请提供一个文件名作为参数" | ||
6 | # exit 1 | ||
7 | # fi | ||
8 | |||
9 | filename=$1 | ||
10 | extension="${filename##*.}" # 获取文件名的扩展名部分 | ||
11 | |||
12 | # 检查文件后缀并执行相应的编译命令 | ||
13 | if [ "$extension" = "c" ]; then | ||
14 | gcc -g -o "${filename%.*}" -g "$filename" $2 | ||
15 | elif [ "$extension" = "cpp" ]; then | ||
16 | g++ -g -o "${filename%.*}" -g "$filename" $2 | ||
17 | else | ||
18 | echo "不支持的文件类型" | ||
19 | exit 1 | ||
20 | fi | ||
21 | |||
22 | exit 0 | ||
diff --git a/mypath/gitadd.sh b/mypath/gitadd.sh new file mode 100755 index 0000000..79e750f --- /dev/null +++ b/mypath/gitadd.sh | |||
@@ -0,0 +1,45 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | read -p "Local repo name: " local_name | ||
4 | read -p "Remote repo name: " remote_name | ||
5 | |||
6 | # 远程仓库创建 | ||
7 | tmp="ssh aliyun-git git init --bare $remote_name.git" | ||
8 | eval "$tmp" | ||
9 | |||
10 | # 本地仓库创建 | ||
11 | mkdir "$local_name" | ||
12 | cd "$local_name" | ||
13 | git init | ||
14 | |||
15 | # 本地仓库初始化 | ||
16 | # 编写.gitignore | ||
17 | cat > .gitignore << EOF | ||
18 | *.sh | ||
19 | *.bat | ||
20 | *.exe | ||
21 | *.[oa] | ||
22 | *.pyc | ||
23 | __pycache__ | ||
24 | *.vscode | ||
25 | *.swp | ||
26 | EOF | ||
27 | |||
28 | # 编写push.sh | ||
29 | cat > push.sh << EOF | ||
30 | git add . | ||
31 | git commit | ||
32 | git push | ||
33 | EOF | ||
34 | chmod +x push.sh | ||
35 | |||
36 | # 提交初始化commit | ||
37 | git add . | ||
38 | git commit -m "Initial commit" | ||
39 | tmp="git remote add origin aliyun-git:$remote_name.git" | ||
40 | eval "$tmp" | ||
41 | git push --set-upstream origin master | ||
42 | git push | ||
43 | |||
44 | echo "Success!" | ||
45 | |||
diff --git a/mypath/gitk.sh b/mypath/gitk.sh new file mode 100755 index 0000000..aa6e515 --- /dev/null +++ b/mypath/gitk.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | git log --oneline --all --graph | ||
diff --git a/mypath/md2html.sh b/mypath/md2html.sh new file mode 100755 index 0000000..bb316f1 --- /dev/null +++ b/mypath/md2html.sh | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : md2html.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2023-12-15 | ||
9 | ########################################################################## | ||
10 | |||
11 | # origin是输入的第一个参数,指源文件名 | ||
12 | # src是原文件名前边加一个.,是源文件的复制 | ||
13 | # dst是原文件名的md后缀改成html | ||
14 | origin=$1 | ||
15 | src="."$origin | ||
16 | dst=${origin%.*}".html" | ||
17 | title="$2" | ||
18 | |||
19 | cp $origin $src | ||
20 | # src中所有的“```...”替换成“```”,其中...指换行前的所有内容 | ||
21 | sed -i 's/```.*$/```/g' $src | ||
22 | pandoc -s $src -o $dst --metadata title="$title" | ||
23 | rm $src | ||
24 | |||
25 | sed -i '/<style/,/<\/style>/d' $dst | ||
26 | sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst | ||
27 | sed -i 's/<\/body>/<script src="https:\/\/www.qin-juan-ge-zhu.top\/common\/js\/comment.js"><\/script>\n<\/div>\n<\/div>\n<\/body>/' $dst | ||
28 | sed -i 's/\t/ /g' $dst | ||
29 | sed -i 's/<\/head>/<link rel="stylesheet" href="https:\/\/www.qin-juan-ge-zhu.top\/common\/CSS\/pandoc.css">\n<script type="text\/javascript" src="https:\/\/www.qin-juan-ge-zhu.top\/common\/script4code.js"><\/script><\/head>/' $dst | ||
diff --git a/mypath/runjv.c b/mypath/runjv.c new file mode 100644 index 0000000..74efb72 --- /dev/null +++ b/mypath/runjv.c | |||
@@ -0,0 +1,39 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | |||
5 | #ifdef _WIN32 | ||
6 | #define DELETE_COMMAND "del" | ||
7 | #else | ||
8 | #define DELETE_COMMAND "rm -rf" | ||
9 | #endif | ||
10 | |||
11 | |||
12 | int main(int argc, char* argv[]) | ||
13 | { | ||
14 | char* command; | ||
15 | if(argc!=2) | ||
16 | { | ||
17 | printf("Number of parameters Wrong!\n"); | ||
18 | printf("Usage: runjv <filename>\n"); | ||
19 | return 1; | ||
20 | } | ||
21 | command=(char*)malloc(sizeof(char)*(strlen(argv[1])+10)); | ||
22 | |||
23 | char* classname=strtok(argv[1],"."); | ||
24 | |||
25 | sprintf(command,"javac %s.java",classname); | ||
26 | int command_status=system(command); | ||
27 | |||
28 | if(command_status!=0) | ||
29 | { | ||
30 | printf("Compile Failed!\n"); | ||
31 | return -1; | ||
32 | } | ||
33 | sprintf(command,"java %s",classname); | ||
34 | system(command); | ||
35 | |||
36 | sprintf(command,"%s %s.class",DELETE_COMMAND,classname); | ||
37 | system(command); | ||
38 | return 0; | ||
39 | } | ||
diff --git a/mypath/runjv.sh b/mypath/runjv.sh new file mode 100755 index 0000000..56eaa05 --- /dev/null +++ b/mypath/runjv.sh | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # 检查参数数量 | ||
4 | if [ $# -ne 1 ]; then | ||
5 | echo "请提供一个Java文件名作为参数" | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | filename=$1 | ||
10 | classname="${filename%.*}" | ||
11 | javac "$filename" | ||
12 | if [ $? -eq 0 ]; then | ||
13 | java "$classname" | ||
14 | rm "$classname.class" | ||
15 | else | ||
16 | echo "Java文件编译失败!" | ||
17 | fi | ||
@@ -13,9 +13,9 @@ if filereadable(expand("/etc/vim/vimrcs/match.vim")) | |||
13 | source /etc/vim/vimrcs/match.vim | 13 | source /etc/vim/vimrcs/match.vim |
14 | endif | 14 | endif |
15 | 15 | ||
16 | " 不道 | 16 | " 栏标签页设置 |
17 | if filereadable(expand("/etc/vim/vimrcs/fuck.vim")) | 17 | if filereadable(expand("/etc/vim/vimrcs/statusline.vim")) |
18 | source /etc/vim/vimrcs/fuck.vim | 18 | source /etc/vim/vimrcs/statusline.vim |
19 | endif | 19 | endif |
20 | 20 | ||
21 | " 自己设的快捷键 | 21 | " 自己设的快捷键 |
@@ -23,7 +23,7 @@ if filereadable(expand("/etc/vim/vimrcs/keybind.vim")) | |||
23 | source /etc/vim/vimrcs/keybind.vim | 23 | source /etc/vim/vimrcs/keybind.vim |
24 | endif | 24 | endif |
25 | 25 | ||
26 | " 自动命 | 26 | " 码设置 |
27 | if filereadable(expand("/etc/vim/vimrcs/autocmd.vim")) | 27 | if filereadable(expand("/etc/vim/vimrcs/codecmd.vim")) |
28 | source /etc/vim/vimrcs/autocmd.vim | 28 | source /etc/vim/vimrcs/codecmd.vim |
29 | endif | 29 | endif |
diff --git a/vim/vimrcs/autocmd.vim b/vim/vimrcs/codecmd.vim index c974344..82b0bfe 100644 --- a/vim/vimrcs/autocmd.vim +++ b/vim/vimrcs/codecmd.vim | |||
@@ -1,11 +1,48 @@ | |||
1 | autocmd BufReadPost,BufWritePre *.html,*.c,*.cpp,*.vim normal gg=G | 1 | set expandtab "设置tab键替换为tabstop规定的空格数 |
2 | "autocmd FileType * :normal gg=G<c-o><c-o> | 2 | set tabstop=4 |
3 | autocmd Filetype c,cpp map <buffer><C-d> 0xx<esc>ta | 3 | set shiftwidth=4 "设置tab的间隔 |
4 | autocmd Filetype python map <buffer><C-d> 0xx<esc>ta | 4 | set softtabstop=4 |
5 | autocmd FileType asm,nasm,vim set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab | ||
5 | 6 | ||
6 | "新建.c,.h,.sh,.java文件,自动插入文件头 | 7 | set showmatch "在输入括号时光标会短暂地跳到与之相匹配的括号处 |
7 | autocmd BufNewFile *.cpp,*.[ch],*.sh exec ":call SetTitle()" | 8 | set wrap "设置自动折行 |
8 | func SetTitle() | 9 | set textwidth=500 "设置自动换行的长度 |
10 | set lbr | ||
11 | "set autoindent "设置自动缩进 | ||
12 | "set smartindent "设置智能缩进 | ||
13 | "set foldmethod=indent "设置按缩进折叠代码 | ||
14 | set foldmethod=syntax "设置按语法折叠代码 | ||
15 | "set foldlevel=99 "折叠层级 | ||
16 | "在打开文件时不要折叠 | ||
17 | set nofoldenable | ||
18 | |||
19 | |||
20 | "自动补全配置 | ||
21 | autocmd FileType python set omnifunc=pythoncomplete#Complete | ||
22 | autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS | ||
23 | autocmd FileType html set omnifunc=htmlcomplete#CompleteTags | ||
24 | autocmd FileType css set omnifunc=csscomplete#CompleteCSS | ||
25 | autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags | ||
26 | autocmd FileType php set omnifunc=phpcomplete#CompletePHP | ||
27 | autocmd FileType c set omnifunc=ccomplete#Complete | ||
28 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 | ||
29 | autocmd BufReadPost,BufWritePre *.html,*.vim normal! g1G=G`"z<CR> | ||
30 | " 在保存时自动使用clang-format格式化代码 | ||
31 | augroup FormatAutocmd | ||
32 | autocmd! | ||
33 | autocmd BufWritePre *.c,*.cpp :normal! ggVG | ||
34 | autocmd BufWritePre *.c,*.cpp :let save_cursor = getpos(".") | ||
35 | autocmd BufWritePre *.c,*.cpp :ClangFormat | ||
36 | autocmd BufWritePost *.c,*.cpp :call setpos('.', save_cursor) | ||
37 | augroup END | ||
38 | " 定义ClangFormat命令 | ||
39 | command! -nargs=0 ClangFormat :silent %!clang-format -style="{IndentWidth: 4}" | ||
40 | " 映射gg=G到ClangFormat | ||
41 | autocmd FileType c,cpp nnoremap <buffer> gg=G :ClangFormat<CR> | ||
42 | |||
43 | "新建.c,.h,.sh,.java文件,自动插入文件头 | ||
44 | autocmd BufNewFile *.cpp,*.[ch],*.sh exec ":call SetTitle()" | ||
45 | func SetTitle() | ||
9 | if &filetype == 'sh' | 46 | if &filetype == 'sh' |
10 | call setline(1,"#!/bin/bash") | 47 | call setline(1,"#!/bin/bash") |
11 | call append(line("."), "" ) | 48 | call append(line("."), "" ) |
@@ -14,28 +51,28 @@ func SetTitle() | |||
14 | call append(line(".")+3, "\# Encoding : utf-8") | 51 | call append(line(".")+3, "\# Encoding : utf-8") |
15 | call append(line(".")+4, "\# Author : We-unite") | 52 | call append(line(".")+4, "\# Author : We-unite") |
16 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | 53 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") |
17 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) | 54 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) |
18 | call append(line(".")+7, "\##########################################################################" ) | 55 | call append(line(".")+7, "\##########################################################################" ) |
19 | call append(line(".")+8, "") | 56 | call append(line(".")+8, "") |
20 | elseif &filetype =='py' | 57 | elseif &filetype =='py' |
21 | call setline(1,"#!/usr/bin/env python") | 58 | call setline(1,"#!/usr/bin/env python") |
22 | call append(line("."), "" ) | 59 | call append(line("."), "" ) |
23 | call append(line(".")+1, "\##########################################################################" ) | 60 | call append(line(".")+1, "\##########################################################################" ) |
24 | call append(line(".")+2, "\# File Name : ".expand("%")) | 61 | call append(line(".")+2, "\# File Name : ".expand("%")) |
25 | call append(line(".")+3, "\# Encoding : utf-8") | 62 | call append(line(".")+3, "\# Encoding : utf-8") |
26 | call append(line(".")+4, "\# Author : We-unite") | 63 | call append(line(".")+4, "\# Author : We-unite") |
27 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | 64 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") |
28 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) | 65 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) |
29 | call append(line(".")+7, "\##########################################################################" ) | 66 | call append(line(".")+7, "\##########################################################################" ) |
30 | call append(line(".")+8, "") | 67 | call append(line(".")+8, "") |
31 | else | 68 | else |
32 | call setline(1, "/*************************************************************************") | 69 | call setline(1, "/*************************************************************************") |
33 | call append(line("."), " > File Name : ".expand("%")) | 70 | call append(line("."), " > File Name : ".expand("%")) |
34 | call append(line(".")+1, " > Encoding : utf-8") | 71 | call append(line(".")+1, " > Encoding : utf-8") |
35 | call append(line(".")+2, " > Author : We-unite") | 72 | call append(line(".")+2, " > Author : We-unite") |
36 | call append(line(".")+3, " > Email : weunite1848@gmail.com ") | 73 | call append(line(".")+3, " > Email : weunite1848@gmail.com ") |
37 | call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d-%H:%M:%S",localtime())) | 74 | call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d %H:%M:%S",localtime())) |
38 | call append(line(".")+5, " ************************************************************************/") | 75 | call append(line(".")+5, " ************************************************************************/") |
39 | call append(line(".")+6, "") | 76 | call append(line(".")+6, "") |
40 | if &filetype == 'cpp' | 77 | if &filetype == 'cpp' |
41 | call append(line(".")+7, "#include <iostream>") | 78 | call append(line(".")+7, "#include <iostream>") |
@@ -49,11 +86,10 @@ func SetTitle() | |||
49 | endif | 86 | endif |
50 | " 光标移动到文件末尾 | 87 | " 光标移动到文件末尾 |
51 | normal G | 88 | normal G |
52 | endfunc | 89 | endfunc |
53 | |||
54 | "C,C++ 按F5编译运行 | ||
55 | map <F5> :call CompileRunGcc()<CR> | ||
56 | 90 | ||
91 | "C,C++编译运行 | ||
92 | map <leader>r :call CompileRunGcc()<CR> | ||
57 | func CompileRunGcc() | 93 | func CompileRunGcc() |
58 | exec "w" | 94 | exec "w" |
59 | if &filetype == 'c' | 95 | if &filetype == 'c' |
@@ -62,7 +98,7 @@ func CompileRunGcc() | |||
62 | elseif &filetype == 'cpp' | 98 | elseif &filetype == 'cpp' |
63 | exec "!g++ -g -o %< %" | 99 | exec "!g++ -g -o %< %" |
64 | exec "! ./%<" | 100 | exec "! ./%<" |
65 | "elseif &filetype == 'java' | 101 | "elseif &filetype == 'java' |
66 | " exec "!javac %" | 102 | " exec "!javac %" |
67 | " exec "!java %<" | 103 | " exec "!java %<" |
68 | elseif &filetype == 'sh' | 104 | elseif &filetype == 'sh' |
@@ -72,9 +108,8 @@ func CompileRunGcc() | |||
72 | endif | 108 | endif |
73 | endfunc | 109 | endfunc |
74 | 110 | ||
75 | "C,C++的调试 | 111 | "C,C++调试 |
76 | map <F8> :call RunGdb()<CR> | 112 | map <leader>d :call RunGdb()<CR> |
77 | |||
78 | func RunGdb() | 113 | func RunGdb() |
79 | exec "w" | 114 | exec "w" |
80 | exec "!gdb ./%<" | 115 | exec "!gdb ./%<" |
diff --git a/vim/vimrcs/match.vim b/vim/vimrcs/match.vim index 279a33f..b01f35d 100644 --- a/vim/vimrcs/match.vim +++ b/vim/vimrcs/match.vim | |||
@@ -1,11 +1,14 @@ | |||
1 | "各类符号自动匹配 | 1 | "各类符号自动匹配 |
2 | inoremap { {<CR>}<ESC>O | ||
3 | " :inoremap { {}<ESC>i | ||
4 | " :inoremap } <c-r>=ClosePair('}')<CR> | ||
2 | :inoremap ( ()<ESC>i | 5 | :inoremap ( ()<ESC>i |
3 | :inoremap ) <c-r>=ClosePair(')')<CR> | 6 | :inoremap ) <c-r>=ClosePair(')')<CR> |
4 | :inoremap { {}<ESC>i | ||
5 | :inoremap } <c-r>=ClosePair('}')<CR> | ||
6 | :inoremap [ []<ESC>i | 7 | :inoremap [ []<ESC>i |
7 | :inoremap ] <c-r>=ClosePair(']')<CR> | 8 | :inoremap ] <c-r>=ClosePair(']')<CR> |
8 | 9 | :inoremap " ""<ESC>i | |
10 | :inoremap ' ''<ESC>i | ||
11 | |||
9 | function ClosePair(char) | 12 | function ClosePair(char) |
10 | if getline('.')[col('.') - 1] == a:char | 13 | if getline('.')[col('.') - 1] == a:char |
11 | return "<Right>" | 14 | return "<Right>" |
diff --git a/vim/vimrcs/myset.vim b/vim/vimrcs/myset.vim index 37e65b5..1664ddb 100644 --- a/vim/vimrcs/myset.vim +++ b/vim/vimrcs/myset.vim | |||
@@ -1,52 +1,26 @@ | |||
1 | set expandtab "设置tab键替换为tabstop规定的空格数 | ||
2 | set tabstop=4 | ||
3 | set shiftwidth=4 "设置tab的间隔 | ||
4 | "set softtabstop=4 | ||
5 | set sts=4 | ||
6 | set showmatch "在输入括号时光标会短暂地跳到与之相匹配的括号处 | ||
7 | set wrap "设置自动折行 | ||
8 | set textwidth=80 "设置自动换行的长度 | ||
9 | set lbr | ||
10 | "set autoindent "设置自动缩进 | ||
11 | "set smartindent "设置智能缩进 | ||
12 | "set foldmethod=indent "设置按缩进折叠代码 | ||
13 | set foldmethod=syntax "设置按语法折叠代码 | ||
14 | "set foldlevel=99 "折叠层级 | ||
15 | "nnoremap <space> za | ||
16 | |||
17 | |||
18 | "set guifont=Monospace | 1 | "set guifont=Monospace |
19 | set guifont=:b:h16 | 2 | set guifont=:b:h16 |
20 | set encoding=utf-8 | 3 | set encoding=utf-8 |
21 | set fileencoding=utf-8 | 4 | set fileencoding=utf-8 |
22 | set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1 | 5 | set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1 |
23 | set fileformat=unix | 6 | set fileformat=unix |
24 | set helplang=cn "帮助中文支持 | 7 | set helplang=cn "帮助中文支持 |
25 | set mouse=a " 设置鼠标 | 8 | set mouse=a " 设置鼠标 |
26 | set noeb " 去掉输入错误的提示声音 | 9 | set noeb " 去掉输入错误的提示声音 |
27 | set confirm " 在处理未保存或只读文件的时候,弹出确认 | 10 | set confirm " 在处理未保存或只读文件的时候,弹出确认 |
28 | set langmenu=zh_CN.UTF-8 | 11 | set langmenu=zh_CN.UTF-8 |
29 | set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | 12 | set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 |
30 | |||
31 | "自动补全配置 | ||
32 | autocmd FileType python set omnifunc=pythoncomplete#Complete | ||
33 | autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS | ||
34 | autocmd FileType html set omnifunc=htmlcomplete#CompleteTags | ||
35 | autocmd FileType css set omnifunc=csscomplete#CompleteCSS | ||
36 | autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags | ||
37 | autocmd FileType php set omnifunc=phpcomplete#CompletePHP | ||
38 | autocmd FileType c set omnifunc=ccomplete#Complete | ||
39 | 13 | ||
40 | set rnu "设置相对行号 | 14 | set rnu "设置相对行号 |
41 | set nu "设置绝对行号 | 15 | set nu "设置绝对行号 |
42 | " Set cursor shape and color | 16 | " Set cursor shape and color |
43 | if &term =~ "xterm" | 17 | if &term =~ "xterm" |
44 | " INSERT mode | 18 | " INSERT mode |
45 | let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7" | 19 | let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7" |
46 | " REPLACE mode | 20 | " REPLACE mode |
47 | let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7" | 21 | let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7" |
48 | " NORMAL mode | 22 | " NORMAL mode |
49 | let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7" | 23 | let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7" |
50 | endif | 24 | endif |
51 | " 1 -> blinking block 闪烁的方块 | 25 | " 1 -> blinking block 闪烁的方块 |
52 | " 2 -> solid block 不闪烁的方块 | 26 | " 2 -> solid block 不闪烁的方块 |
@@ -59,8 +33,7 @@ syntax on | |||
59 | set cul | 33 | set cul |
60 | set cuc | 34 | set cuc |
61 | hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white | 35 | hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white |
62 | colorscheme industry "设置颜色主题 | 36 | colorscheme industry "设置颜色主题 |
63 | ""set lines=35 columns=118 | 37 | set list "显示tab和空格 |
64 | "set list "显示tab和空格 | 38 | set listchars=tab:>-,trail:- "设置tab和空格的显示 |
65 | "set listchars=tab:>-,trail:. "设置tab和空格的显示 | 39 | hi SpecialKey ctermfg=red guifg=red |
66 | "hi SpecialKey ctermfg=red guifg=red | ||
diff --git a/vim/vimrcs/plugs.vim b/vim/vimrcs/plugs.vim index cfd0136..4606f3d 100644 --- a/vim/vimrcs/plugs.vim +++ b/vim/vimrcs/plugs.vim | |||
@@ -1,21 +1,21 @@ | |||
1 | " Vundle插件管理器配置 | 1 | " Vundle插件管理器配置 |
2 | set nocompatible "去除VIM一致性,必须 | 2 | set nocompatible "去除VIM一致性,必须 |
3 | filetype off "必须 | 3 | filetype off "必须 |
4 | 4 | ||
5 | "设置包括vundle和初始化相关的运行时路径" | 5 | "设置包括vundle和初始化相关的运行时路径" |
6 | set rtp+=/home/player/useful/bundle/Vundle.vim | 6 | set rtp+=/home/player/useful/bundle/Vundle.vim |
7 | call vundle#begin('/home/player/useful/bundle') | 7 | call vundle#begin('/home/player/useful/bundle') |
8 | 8 | ||
9 | Plugin 'VundleVim/Vundle.vim' "启用vundle管理插件,必须 | 9 | Plugin 'VundleVim/Vundle.vim' "启用vundle管理插件,必须 |
10 | Plugin 'Valloric/YouCompleteMe' "代码补全插件 | 10 | Plugin 'Valloric/YouCompleteMe' "代码补全插件 |
11 | Plugin 'preservim/nerdtree' "文件目录树插件 | 11 | Plugin 'preservim/nerdtree' "文件目录树插件 |
12 | Plugin 'Xuyuanp/nerdtree-git-plugin' "nerdtree git支持 | 12 | Plugin 'Xuyuanp/nerdtree-git-plugin' "nerdtree git支持 |
13 | Plugin 'skywind3000/vim-terminal-help' "vim-terminal-help插件 | 13 | Plugin 'skywind3000/vim-terminal-help' "vim-terminal-help插件 |
14 | Plugin 'scrooloose/syntastic' "语法检查插件 | 14 | Plugin 'scrooloose/syntastic' "语法检查插件 |
15 | "Plugin 'Lokaltog/powerline',{'rtp':'powerline/bindings/vim/'} "状态栏信息插件 | 15 | "Plugin 'Lokaltog/powerline',{'rtp':'powerline/bindings/vim/'} "状态栏信息插件 |
16 | Plugin 'github/copilot.vim' "GitHub Copilot插件 | 16 | Plugin 'github/copilot.vim' "GitHub Copilot插件 |
17 | Plugin 'voldikss/vim-translator' "翻译插件 | 17 | Plugin 'voldikss/vim-translator' "翻译插件 |
18 | Plugin 'yegappan/taglist' "taglist插件 | 18 | Plugin 'yegappan/taglist' "taglist插件 |
19 | 19 | ||
20 | call vundle#end() | 20 | call vundle#end() |
21 | filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须 | 21 | filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须 |
@@ -44,11 +44,10 @@ autocmd bufenter * if(winnr('$') ==1 && exists('b:NERDTree') && b:NERDTree.isTab | |||
44 | nmap <F2> :NERDTreeToggle<CR> | 44 | nmap <F2> :NERDTreeToggle<CR> |
45 | nmap T :NERDTreeToggle<CR> | 45 | nmap T :NERDTreeToggle<CR> |
46 | let g:NERDTreeDirArrowExpandable = '+' | 46 | let g:NERDTreeDirArrowExpandable = '+' |
47 | let g:NERDTreeDirArrowCollapsible = '-' "修改树的显示图标 | 47 | let g:NERDTreeDirArrowCollapsible = '-' "修改树的显示图标 |
48 | "let g:NERDTreeWinPos='left' "窗口位置 | 48 | let g:NERDTreeWinPos='left' "窗口位置 |
49 | let g:NERDTreeSize=10 "窗口尺寸 | 49 | let g:NERDTreeSize=10 "窗口尺寸 |
50 | let g:NERDTreeShowLineNumbers=1 "窗口是否显示行号 | 50 | let g:NERDTreeShowLineNumbers=1 "窗口是否显示行号 |
51 | "let g:NERDTreeHidden=1 "似乎是隐藏文件的旧命令?没看到作用 | ||
52 | let NERDTreeShowHidden=1 "显示隐藏文件 | 51 | let NERDTreeShowHidden=1 "显示隐藏文件 |
53 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] "过滤: 所有指定文件和文件夹不显示 | 52 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] "过滤: 所有指定文件和文件夹不显示 |
54 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif "在每个标签页打开相同的文件树 | 53 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif "在每个标签页打开相同的文件树 |
@@ -109,13 +108,18 @@ nmap <silent> <Leader>x <Plug>TranslateX | |||
109 | 108 | ||
110 | "进行Taglist的设置 | 109 | "进行Taglist的设置 |
111 | map <F3> :TlistToggle<CR> | 110 | map <F3> :TlistToggle<CR> |
112 | map <F3> :silent Tlist<CR> "按下F3就可以呼出了 | 111 | map <F3> :silent Tlist<CR> " 按下F3就可以呼出了 |
113 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' "因为我们放在环境变量里,所以可以直接执行 | 112 | map <space>tl :silent Tlist<CR> " 按下F3就可以呼出了 |
114 | let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边 | 113 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' "因为我们放在环境变量里,所以可以直接执行 |
115 | let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表 | 114 | let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边 |
116 | let Tlist_File_Fold_Auto_Close=0 "非当前文件列表折叠隐藏 | 115 | let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表 |
116 | let Tlist_File_Fold_Auto_Close=0 "非当前文件列表折叠隐藏 | ||
117 | let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim | ||
118 | let Tlist_Process_File_Always=1 "是否一直处理tags.1:处理;0:不处理 | ||
119 | let Tlist_Inc_Winwidth=1 "不是一直实时更新tags,因为没有必要 | ||
120 | " 每隔多少秒更新一次tags,如果为0则不更新 | ||
121 | let Tlist_Update_Time=5 | ||
117 | " 在每个标签页打开相同的函数列表 | 122 | " 在每个标签页打开相同的函数列表 |
118 | autocmd BufWinEnter * if getcmdwintype() == '' | silent TlistUpdate | endif | 123 | autocmd BufWinEnter * if getcmdwintype() == '' | silent TlistUpdate | endif |
119 | let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim | 124 | " 打开新标签页时自动打开函数列表 |
120 | let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理 | 125 | autocmd BufWinEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.IsTabTree()) | silent TlistToggle | endif |
121 | let Tlist_Inc_Winwidth=1 "不是一直实时更新tags,因为没有必要 | ||
diff --git a/vim/vimrcs/fuck.vim b/vim/vimrcs/statusline.vim index d149b0b..7bdee34 100644 --- a/vim/vimrcs/fuck.vim +++ b/vim/vimrcs/statusline.vim | |||
@@ -51,7 +51,7 @@ function! GitBranch() | |||
51 | endfunction | 51 | endfunction |
52 | 52 | ||
53 | set laststatus=2 "显示状态栏(默认值为 1,无法显示状态栏) | 53 | set laststatus=2 "显示状态栏(默认值为 1,无法显示状态栏) |
54 | set statusline=%f%m%r%h%w\ >\ %{GitBranch()}%=\ <\ %{&ff}\ <\ %y\ <\ %l,%v\ <\ %p%%\ <\ lines=%L | 54 | set statusline=%f%m%r%h%w\ >\ %{GitBranch()}%=\ <\ %{&ff},\ %{&fenc}\ <\ %y\ <\ %l,%v\ <\ %p%%\ <\ lines=%L |
55 | 55 | ||
56 | function! CurDir() | 56 | function! CurDir() |
57 | let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") | 57 | let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") |