diff options
author | 2023-10-24 11:18:40 +0800 | |
---|---|---|
committer | 2023-10-24 11:18:40 +0800 | |
commit | 6d31cdcd10dfead571c3ab3ae48c161efe4cef16 (patch) | |
tree | 34b43687edc8e3dd378b81d95d5b37824bf7dcf3 | |
parent | 094ab00cf5d9b426af519de519b0c723ce34e54c (diff) | |
download | Pardon-6d31cdcd10dfead571c3ab3ae48c161efe4cef16.tar.gz Pardon-6d31cdcd10dfead571c3ab3ae48c161efe4cef16.zip |
vim
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | vim/vimrc | 29 | ||||
-rw-r--r-- | vim/vimrc.tiny | 13 | ||||
-rw-r--r-- | vim/vimrc_origin | 55 | ||||
-rw-r--r-- | vim/vimrcs/autocmd.vim | 81 | ||||
-rw-r--r-- | vim/vimrcs/fuck.vim | 69 | ||||
-rw-r--r-- | vim/vimrcs/keybind.vim | 34 | ||||
-rw-r--r-- | vim/vimrcs/match.vim | 15 | ||||
-rw-r--r-- | vim/vimrcs/myset.vim | 66 | ||||
-rw-r--r-- | vim/vimrcs/plugs.vim | 121 | ||||
-rw-r--r-- | vim/vimscript.vim | 295 |
11 files changed, 778 insertions, 2 deletions
@@ -1,3 +1 @@ | |||
1 | * | ||
2 | !*.* | ||
3 | push.sh | push.sh | |
diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..34bb9cc --- /dev/null +++ b/vim/vimrc | |||
@@ -0,0 +1,29 @@ | |||
1 | " Vundle插件管理及插件内容 | ||
2 | if filereadable(expand("/etc/vim/vimrcs/plugs.vim")) | ||
3 | source /etc/vim/vimrcs/plugs.vim | ||
4 | endif | ||
5 | |||
6 | " 自行设置 | ||
7 | if filereadable(expand("/etc/vim/vimrcs/myset.vim")) | ||
8 | source /etc/vim/vimrcs/myset.vim | ||
9 | endif | ||
10 | |||
11 | " 符号自动匹配 | ||
12 | if filereadable(expand("/etc/vim/vimrcs/match.vim")) | ||
13 | source /etc/vim/vimrcs/match.vim | ||
14 | endif | ||
15 | |||
16 | " 不知道是什么 | ||
17 | if filereadable(expand("/etc/vim/vimrcs/fuck.vim")) | ||
18 | source /etc/vim/vimrcs/fuck.vim | ||
19 | endif | ||
20 | |||
21 | " 自己设的快捷键 | ||
22 | if filereadable(expand("/etc/vim/vimrcs/keybind.vim")) | ||
23 | source /etc/vim/vimrcs/keybind.vim | ||
24 | endif | ||
25 | |||
26 | " 自动命令 | ||
27 | if filereadable(expand("/etc/vim/vimrcs/autocmd.vim")) | ||
28 | source /etc/vim/vimrcs/autocmd.vim | ||
29 | endif | ||
diff --git a/vim/vimrc.tiny b/vim/vimrc.tiny new file mode 100644 index 0000000..890037a --- /dev/null +++ b/vim/vimrc.tiny | |||
@@ -0,0 +1,13 @@ | |||
1 | " Vim configuration file, in effect when invoked as "vi". The aim of this | ||
2 | " configuration file is to provide a Vim environment as compatible with the | ||
3 | " original vi as possible. Note that ~/.vimrc configuration files as other | ||
4 | " configuration files in the runtimepath are still sourced. | ||
5 | " When Vim is invoked differently ("vim", "view", "evim", ...) this file is | ||
6 | " _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are. | ||
7 | |||
8 | " Debian system-wide default configuration Vim | ||
9 | set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after | ||
10 | |||
11 | set compatible | ||
12 | |||
13 | " vim: set ft=vim: | ||
diff --git a/vim/vimrc_origin b/vim/vimrc_origin new file mode 100644 index 0000000..1fcd4d7 --- /dev/null +++ b/vim/vimrc_origin | |||
@@ -0,0 +1,55 @@ | |||
1 | " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by | ||
2 | " the call to :runtime you can find below. If you wish to change any of those | ||
3 | " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim | ||
4 | " will be overwritten everytime an upgrade of the vim packages is performed. | ||
5 | " It is recommended to make changes after sourcing debian.vim since it alters | ||
6 | " the value of the 'compatible' option. | ||
7 | |||
8 | runtime! debian.vim | ||
9 | |||
10 | " Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc. | ||
11 | " This happens after /etc/vim/vimrc(.local) are loaded, so it will override | ||
12 | " any settings in these files. | ||
13 | " If you don't want that to happen, uncomment the below line to prevent | ||
14 | " defaults.vim from being loaded. | ||
15 | " let g:skip_defaults_vim = 1 | ||
16 | |||
17 | " Uncomment the next line to make Vim more Vi-compatible | ||
18 | " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous | ||
19 | " options, so any other options should be set AFTER setting 'compatible'. | ||
20 | "set compatible | ||
21 | |||
22 | " Vim5 and later versions support syntax highlighting. Uncommenting the next | ||
23 | " line enables syntax highlighting by default. | ||
24 | if has("syntax") | ||
25 | syntax on | ||
26 | endif | ||
27 | |||
28 | " If using a dark background within the editing area and syntax highlighting | ||
29 | " turn on this option as well | ||
30 | "set background=dark | ||
31 | |||
32 | " Uncomment the following to have Vim jump to the last position when | ||
33 | " reopening a file | ||
34 | "au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | ||
35 | |||
36 | " Uncomment the following to have Vim load indentation rules and plugins | ||
37 | " according to the detected filetype. | ||
38 | "filetype plugin indent on | ||
39 | |||
40 | " The following are commented out as they cause vim to behave a lot | ||
41 | " differently from regular Vi. They are highly recommended though. | ||
42 | "set showcmd " Show (partial) command in status line. | ||
43 | "set showmatch " Show matching brackets. | ||
44 | "set ignorecase " Do case insensitive matching | ||
45 | "set smartcase " Do smart case matching | ||
46 | "set incsearch " Incremental search | ||
47 | "set autowrite " Automatically save before commands like :next and :make | ||
48 | "set hidden " Hide buffers when they are abandoned | ||
49 | "set mouse=a " Enable mouse usage (all modes) | ||
50 | |||
51 | " Source a global configuration file if available | ||
52 | if filereadable("/etc/vim/vimrc.local") | ||
53 | source /etc/vim/vimrc.local | ||
54 | endif | ||
55 | |||
diff --git a/vim/vimrcs/autocmd.vim b/vim/vimrcs/autocmd.vim new file mode 100644 index 0000000..c974344 --- /dev/null +++ b/vim/vimrcs/autocmd.vim | |||
@@ -0,0 +1,81 @@ | |||
1 | autocmd BufReadPost,BufWritePre *.html,*.c,*.cpp,*.vim normal gg=G | ||
2 | "autocmd FileType * :normal gg=G<c-o><c-o> | ||
3 | autocmd Filetype c,cpp map <buffer><C-d> 0xx<esc>ta | ||
4 | autocmd Filetype python map <buffer><C-d> 0xx<esc>ta | ||
5 | |||
6 | "新建.c,.h,.sh,.java文件,自动插入文件头 | ||
7 | autocmd BufNewFile *.cpp,*.[ch],*.sh exec ":call SetTitle()" | ||
8 | func SetTitle() | ||
9 | if &filetype == 'sh' | ||
10 | call setline(1,"#!/bin/bash") | ||
11 | call append(line("."), "" ) | ||
12 | call append(line(".")+1, "\##########################################################################" ) | ||
13 | call append(line(".")+2, "\# File Name : ".expand("%")) | ||
14 | call append(line(".")+3, "\# Encoding : utf-8") | ||
15 | call append(line(".")+4, "\# Author : We-unite") | ||
16 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | ||
17 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) | ||
18 | call append(line(".")+7, "\##########################################################################" ) | ||
19 | call append(line(".")+8, "") | ||
20 | elseif &filetype =='py' | ||
21 | call setline(1,"#!/usr/bin/env python") | ||
22 | call append(line("."), "" ) | ||
23 | call append(line(".")+1, "\##########################################################################" ) | ||
24 | call append(line(".")+2, "\# File Name : ".expand("%")) | ||
25 | call append(line(".")+3, "\# Encoding : utf-8") | ||
26 | call append(line(".")+4, "\# Author : We-unite") | ||
27 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | ||
28 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime())) | ||
29 | call append(line(".")+7, "\##########################################################################" ) | ||
30 | call append(line(".")+8, "") | ||
31 | else | ||
32 | call setline(1, "/*************************************************************************") | ||
33 | call append(line("."), " > File Name : ".expand("%")) | ||
34 | call append(line(".")+1, " > Encoding : utf-8") | ||
35 | call append(line(".")+2, " > Author : We-unite") | ||
36 | call append(line(".")+3, " > Email : weunite1848@gmail.com ") | ||
37 | call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d-%H:%M:%S",localtime())) | ||
38 | call append(line(".")+5, " ************************************************************************/") | ||
39 | call append(line(".")+6, "") | ||
40 | if &filetype == 'cpp' | ||
41 | call append(line(".")+7, "#include <iostream>") | ||
42 | call append(line(".")+8, "using namespace std;") | ||
43 | call append(line(".")+9, "") | ||
44 | elseif &filetype == 'c' | ||
45 | call append(line(".")+7, "#include <stdio.h>") | ||
46 | call append(line(".")+8, "#include <stdlib.h>") | ||
47 | call append(line(".")+9, "") | ||
48 | endif | ||
49 | endif | ||
50 | " 光标移动到文件末尾 | ||
51 | normal G | ||
52 | endfunc | ||
53 | |||
54 | "C,C++ 按F5编译运行 | ||
55 | map <F5> :call CompileRunGcc()<CR> | ||
56 | |||
57 | func CompileRunGcc() | ||
58 | exec "w" | ||
59 | if &filetype == 'c' | ||
60 | exec "!gcc -g -o %< %" | ||
61 | exec "! ./%<" | ||
62 | elseif &filetype == 'cpp' | ||
63 | exec "!g++ -g -o %< %" | ||
64 | exec "! ./%<" | ||
65 | "elseif &filetype == 'java' | ||
66 | " exec "!javac %" | ||
67 | " exec "!java %<" | ||
68 | elseif &filetype == 'sh' | ||
69 | :!./% | ||
70 | elseif &filetype == 'python' | ||
71 | exec "!python %" | ||
72 | endif | ||
73 | endfunc | ||
74 | |||
75 | "C,C++的调试 | ||
76 | map <F8> :call RunGdb()<CR> | ||
77 | |||
78 | func RunGdb() | ||
79 | exec "w" | ||
80 | exec "!gdb ./%<" | ||
81 | endfunc | ||
diff --git a/vim/vimrcs/fuck.vim b/vim/vimrcs/fuck.vim new file mode 100644 index 0000000..d149b0b --- /dev/null +++ b/vim/vimrcs/fuck.vim | |||
@@ -0,0 +1,69 @@ | |||
1 | set guitablabel=%{ShortTabLabel()} | ||
2 | function ShortTabLabel () | ||
3 | let bufnrlist = tabpagebuflist (v:lnum) | ||
4 | let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1]) | ||
5 | let filename = fnamemodify (label, ':t') | ||
6 | return filename | ||
7 | endfunction | ||
8 | |||
9 | set tabline=%!MyTabLine() | ||
10 | function MyTabLine() | ||
11 | let s = '' | ||
12 | for i in range(tabpagenr('$')) | ||
13 | " 选择高亮 | ||
14 | if i + 1 == tabpagenr() | ||
15 | let s .= '%#TabLineSel#' | ||
16 | else | ||
17 | let s .= '%#TabLine#' | ||
18 | endif | ||
19 | " 设置标签页号 (用于鼠标点击) | ||
20 | let s .= '%' . (i + 1) . 'T' | ||
21 | " MyTabLabel() 提供完整路径标签 MyShortTabLabel 提供文件名标签 | ||
22 | let s .= ' %{MyShortTabLabel(' . (i + 1) . ')} ' | ||
23 | endfor | ||
24 | " 最后一个标签页之后用 TabLineFill 填充并复位标签页号 | ||
25 | let s .= '%#TabLineFill#%T' | ||
26 | " 右对齐用于关闭当前标签页的标签 | ||
27 | if tabpagenr('$') > 1 | ||
28 | let s .= '%=%#TabLine#%999Xclose' | ||
29 | endif | ||
30 | return s | ||
31 | endfunction | ||
32 | " 文件名标签 | ||
33 | function MyShortTabLabel(n) | ||
34 | let buflist = tabpagebuflist(a:n) | ||
35 | let label = bufname (buflist[tabpagewinnr (a:n) -1]) | ||
36 | let filename = fnamemodify (label, ':t') | ||
37 | return filename | ||
38 | endfunction | ||
39 | "完整路径标签 | ||
40 | function MyTabLabel(n) | ||
41 | let buflist = tabpagebuflist(a:n) | ||
42 | let winnr = tabpagewinnr(a:n) | ||
43 | return bufname(buflist[winnr - 1]) | ||
44 | endfunction | ||
45 | |||
46 | " 状态栏显示git分支函数 | ||
47 | function! GitBranch() | ||
48 | " 获取当前所在分支名,注意不要保留开头的*和行末的空符号 | ||
49 | let s:branch = system("git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/' | tr -d '\n' | tr -d ' '") | ||
50 | return strlen(s:branch) ? 'b: '.s:branch.'> ' : '' | ||
51 | endfunction | ||
52 | |||
53 | set laststatus=2 "显示状态栏(默认值为 1,无法显示状态栏) | ||
54 | set statusline=%f%m%r%h%w\ >\ %{GitBranch()}%=\ <\ %{&ff}\ <\ %y\ <\ %l,%v\ <\ %p%%\ <\ lines=%L | ||
55 | |||
56 | function! CurDir() | ||
57 | let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") | ||
58 | return curdir | ||
59 | endfunction | ||
60 | |||
61 | "标签样式 | ||
62 | " TabLineFill tab pages line, where there are no labels | ||
63 | hi TabLineFill term=none | ||
64 | hi TabLineFill ctermfg=DarkGrey | ||
65 | hi TabLineFill guifg=#777777 | ||
66 | " TabLineSel tab pages line, active tab page label | ||
67 | hi TabLineSel term=inverse | ||
68 | hi TabLineSel cterm=none ctermfg=yellow ctermbg=Black | ||
69 | hi TabLineSel gui=none guifg=yellow guibg=Black | ||
diff --git a/vim/vimrcs/keybind.vim b/vim/vimrcs/keybind.vim new file mode 100644 index 0000000..270cd96 --- /dev/null +++ b/vim/vimrcs/keybind.vim | |||
@@ -0,0 +1,34 @@ | |||
1 | map - dd | ||
2 | map H 0 | ||
3 | map J :<C-u>exe "normal! ".v:count1*10."j"<CR> | ||
4 | map K :<C-u>exe "normal! ".v:count1*10."k"<CR> | ||
5 | map L $ | ||
6 | nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面 | ||
7 | nmap <c-s> :w !sudo tee %<cr>L<cr> | ||
8 | nmap <leader>p <c-x><c-f> "补全路径 | ||
9 | "nmap <C-tab> :tabn<CR> | ||
10 | nmap <tab> :tabp<CR> | ||
11 | "nmap <alt-tab> :tabnew<CR> | ||
12 | "map <space>= <buffer><esc>:vertical resize +5<cr> | ||
13 | "map <space>- <esc>:vertical resize -5<cr> | ||
14 | |||
15 | nnoremap <M-1> 1gt | ||
16 | nnoremap <M-2> 2gt | ||
17 | nnoremap <M-3> 3gt | ||
18 | nnoremap <M-4> 4gt | ||
19 | nnoremap <M-5> 5gt | ||
20 | nnoremap <M-6> 6gt | ||
21 | nnoremap <M-7> 7gt | ||
22 | nnoremap <M-8> 8gt | ||
23 | nnoremap <M-9> 9gt | ||
24 | nnoremap <M-0> :tablast<CR> | ||
25 | |||
26 | "光标在页面间切换 | ||
27 | nnoremap <space>h <C-w><C-h> | ||
28 | nnoremap <space>j <C-w><C-j> | ||
29 | nnoremap <space>k <C-w><C-k> | ||
30 | nnoremap <space>l <C-w><C-l> | ||
31 | |||
32 | "复制粘贴 | ||
33 | vnoremap <C-y> "+y | ||
34 | nnoremap <C-p> "+p | ||
diff --git a/vim/vimrcs/match.vim b/vim/vimrcs/match.vim new file mode 100644 index 0000000..279a33f --- /dev/null +++ b/vim/vimrcs/match.vim | |||
@@ -0,0 +1,15 @@ | |||
1 | "各类符号自动匹配 | ||
2 | :inoremap ( ()<ESC>i | ||
3 | :inoremap ) <c-r>=ClosePair(')')<CR> | ||
4 | :inoremap { {}<ESC>i | ||
5 | :inoremap } <c-r>=ClosePair('}')<CR> | ||
6 | :inoremap [ []<ESC>i | ||
7 | :inoremap ] <c-r>=ClosePair(']')<CR> | ||
8 | |||
9 | function ClosePair(char) | ||
10 | if getline('.')[col('.') - 1] == a:char | ||
11 | return "<Right>" | ||
12 | else | ||
13 | return a:char | ||
14 | endif | ||
15 | endfunction | ||
diff --git a/vim/vimrcs/myset.vim b/vim/vimrcs/myset.vim new file mode 100644 index 0000000..37e65b5 --- /dev/null +++ b/vim/vimrcs/myset.vim | |||
@@ -0,0 +1,66 @@ | |||
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 | ||
19 | set guifont=:b:h16 | ||
20 | set encoding=utf-8 | ||
21 | set fileencoding=utf-8 | ||
22 | set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1 | ||
23 | set fileformat=unix | ||
24 | set helplang=cn "帮助中文支持 | ||
25 | set mouse=a " 设置鼠标 | ||
26 | set noeb " 去掉输入错误的提示声音 | ||
27 | set confirm " 在处理未保存或只读文件的时候,弹出确认 | ||
28 | set langmenu=zh_CN.UTF-8 | ||
29 | 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 | |||
40 | set rnu "设置相对行号 | ||
41 | set nu "设置绝对行号 | ||
42 | " Set cursor shape and color | ||
43 | if &term =~ "xterm" | ||
44 | " INSERT mode | ||
45 | let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7" | ||
46 | " REPLACE mode | ||
47 | let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7" | ||
48 | " NORMAL mode | ||
49 | let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7" | ||
50 | endif | ||
51 | " 1 -> blinking block 闪烁的方块 | ||
52 | " 2 -> solid block 不闪烁的方块 | ||
53 | " 3 -> blinking underscore 闪烁的下划线 | ||
54 | " 4 -> solid underscore 不闪烁的下划线 | ||
55 | " 5 -> blinking vertical bar 闪烁的竖线 | ||
56 | " 6 -> solid vertical bar 不闪烁的竖线 | ||
57 | |||
58 | syntax on | ||
59 | set cul | ||
60 | set cuc | ||
61 | hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white | ||
62 | colorscheme industry "设置颜色主题 | ||
63 | ""set lines=35 columns=118 | ||
64 | "set list "显示tab和空格 | ||
65 | "set listchars=tab:>-,trail:. "设置tab和空格的显示 | ||
66 | "hi SpecialKey ctermfg=red guifg=red | ||
diff --git a/vim/vimrcs/plugs.vim b/vim/vimrcs/plugs.vim new file mode 100644 index 0000000..cfd0136 --- /dev/null +++ b/vim/vimrcs/plugs.vim | |||
@@ -0,0 +1,121 @@ | |||
1 | " Vundle插件管理器配置 | ||
2 | set nocompatible "去除VIM一致性,必须 | ||
3 | filetype off "必须 | ||
4 | |||
5 | "设置包括vundle和初始化相关的运行时路径" | ||
6 | set rtp+=/home/player/useful/bundle/Vundle.vim | ||
7 | call vundle#begin('/home/player/useful/bundle') | ||
8 | |||
9 | Plugin 'VundleVim/Vundle.vim' "启用vundle管理插件,必须 | ||
10 | Plugin 'Valloric/YouCompleteMe' "代码补全插件 | ||
11 | Plugin 'preservim/nerdtree' "文件目录树插件 | ||
12 | Plugin 'Xuyuanp/nerdtree-git-plugin' "nerdtree git支持 | ||
13 | Plugin 'skywind3000/vim-terminal-help' "vim-terminal-help插件 | ||
14 | Plugin 'scrooloose/syntastic' "语法检查插件 | ||
15 | "Plugin 'Lokaltog/powerline',{'rtp':'powerline/bindings/vim/'} "状态栏信息插件 | ||
16 | Plugin 'github/copilot.vim' "GitHub Copilot插件 | ||
17 | Plugin 'voldikss/vim-translator' "翻译插件 | ||
18 | Plugin 'yegappan/taglist' "taglist插件 | ||
19 | |||
20 | call vundle#end() | ||
21 | filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须 | ||
22 | |||
23 | " YouCompleteMe | ||
24 | let g:ycm_global_ycm_extra_conf='/home/player/useful/bundle/YouCompleteMe/.ycm_extra_conf.py' | ||
25 | let g:ycm_key_invoke_completion = '<C-c>' | ||
26 | let g:ycm_semantic_triggers = { | ||
27 | \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], | ||
28 | \ 'cs,lua,javascript': ['re!\w{2}'], | ||
29 | \ } | ||
30 | highlight PMenu ctermfg=34 ctermbg=21 guifg=darkred guibg=darkblue | ||
31 | highlight PMenuSel ctermfg=21 ctermbg=34 guifg=darkblue guibg=darkred | ||
32 | let g:ycm_autoclose_preview_window_after_completion=1 | ||
33 | nnoremap <leader>gf :YcmCompleter GoToDeclaration<CR> | ||
34 | nnoremap <leader>gf :YcmCompleter GoToDefinition<CR> | ||
35 | nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR> | ||
36 | nnoremap <leader>gr :YcmCompleter GoToReferences<CR> | ||
37 | let g:ycm_min_num_of_chars_for_completion=3 | ||
38 | |||
39 | "NERDTree | ||
40 | "autocmd vimenter * NERDTree "进入vim自动打开nerdtree | ||
41 | "当nerdtree为当前标签页剩余唯一窗口时自动关闭 | ||
42 | autocmd bufenter * if(winnr('$') ==1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | quit | endif | ||
43 | "F2键开关文件目录树,注意shift+i切换是否显示隐藏文件 | ||
44 | nmap <F2> :NERDTreeToggle<CR> | ||
45 | nmap T :NERDTreeToggle<CR> | ||
46 | let g:NERDTreeDirArrowExpandable = '+' | ||
47 | let g:NERDTreeDirArrowCollapsible = '-' "修改树的显示图标 | ||
48 | "let g:NERDTreeWinPos='left' "窗口位置 | ||
49 | let g:NERDTreeSize=10 "窗口尺寸 | ||
50 | let g:NERDTreeShowLineNumbers=1 "窗口是否显示行号 | ||
51 | "let g:NERDTreeHidden=1 "似乎是隐藏文件的旧命令?没看到作用 | ||
52 | let NERDTreeShowHidden=1 "显示隐藏文件 | ||
53 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] "过滤: 所有指定文件和文件夹不显示 | ||
54 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif "在每个标签页打开相同的文件树 | ||
55 | |||
56 | |||
57 | "nerdtree-git-plugin | ||
58 | let g:NERDTreeGitStatusIndicatorMapCustom = { | ||
59 | \ 'Dirty' :'Dty', | ||
60 | \ 'Modified' :'M', | ||
61 | \ 'Staged' :'Sta', | ||
62 | \ 'Untracked' :'U', | ||
63 | \ 'Renamed' :'R', | ||
64 | \ 'Unmerged' :'Umg', | ||
65 | \ 'Deleted' :'X', | ||
66 | \ 'Ignored' :'Ign', | ||
67 | \ 'Clean' :'Cl', | ||
68 | \ 'Unknown' :'?', | ||
69 | \ } | ||
70 | let g:NERDTreeGitStatusShowIgnored = 1 "a heavy feature may cost much more time. default: 0 | ||
71 | let g:NERDTreeGitStatusUntrackedFilesMode = 'all' "a heavy feature too. default: normal | ||
72 | |||
73 | "vim-terminal-help | ||
74 | "set termwinsize=10*106 | ||
75 | "let g:terminal_key = '' | ||
76 | "设置光标在终端与编辑器间切换的快捷键 | ||
77 | |||
78 | "syntastic | ||
79 | "YouCompleteMe插件对该插件支持过于优秀,一般不再需要配置,故废弃 | ||
80 | let g:syntastic_python_checkers=['pylint'] | ||
81 | let g:syntastic_python_pylint_args=['--disable=C0111,R0903,C0301'] | ||
82 | "GNU as汇编语言语法检查,需要安装as86和ld86 | ||
83 | let g:syntastic_asm_checkers=['as86'] | ||
84 | "" syntastic end | ||
85 | |||
86 | " powerline | ||
87 | let laststatus=2 | ||
88 | let g:airlinr_powerline_fonts=1 "使用官方打过补丁的字体 | ||
89 | let g:Powerline_symbols='fancy' | ||
90 | |||
91 | "vim-translator | ||
92 | let g:translator_target_lang = 'zh' | ||
93 | let g:translator_source_lang = 'auto' | ||
94 | let g:translator_default_engines = ['youdao', 'bing', 'haici'] | ||
95 | let g:translator_history_enable = v:true | ||
96 | let g:translator_window_type = 'popup' "可选值为 'popup' 和 'preview',默认为 'popup' | ||
97 | " Echo translation in the cmdline | ||
98 | nmap <silent> <Leader>t <Plug>Translate | ||
99 | vmap <silent> <Leader>t <Plug>TranslateV | ||
100 | " Display translation in a window | ||
101 | nmap <silent> <Leader>w <Plug>TranslateW | ||
102 | vmap <silent> <Leader>w <Plug>TranslateWV | ||
103 | " Replace the text with translation | ||
104 | nmap <silent> <Leader>r <Plug>TranslateR | ||
105 | vmap <silent> <Leader>r <Plug>TranslateRV | ||
106 | " Translate the text in clipboard | ||
107 | nmap <silent> <Leader>x <Plug>TranslateX | ||
108 | |||
109 | |||
110 | "进行Taglist的设置 | ||
111 | map <F3> :TlistToggle<CR> | ||
112 | map <F3> :silent Tlist<CR> "按下F3就可以呼出了 | ||
113 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' "因为我们放在环境变量里,所以可以直接执行 | ||
114 | let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边 | ||
115 | let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表 | ||
116 | let Tlist_File_Fold_Auto_Close=0 "非当前文件列表折叠隐藏 | ||
117 | " 在每个标签页打开相同的函数列表 | ||
118 | autocmd BufWinEnter * if getcmdwintype() == '' | silent TlistUpdate | endif | ||
119 | let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim | ||
120 | let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理 | ||
121 | let Tlist_Inc_Winwidth=1 "不是一直实时更新tags,因为没有必要 | ||
diff --git a/vim/vimscript.vim b/vim/vimscript.vim new file mode 100644 index 0000000..001b060 --- /dev/null +++ b/vim/vimscript.vim | |||
@@ -0,0 +1,295 @@ | |||
1 | " 主要参考 http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html | ||
2 | " 额外添加了 ctags, YouCompleteMe等 | ||
3 | " 主要特点 | ||
4 | |||
5 | "1.按F5可以直接编译并执行C、C++、java代码以及执行shell脚本,按“F8”可进行C、C++代码的调试 | ||
6 | "2.自动插入文件头 ,新建C、C++源文件时自动插入表头:包括文件名、作者、联系方式、建立时间等,读者可根据需求自行更改 | ||
7 | "3.映射“Ctrl + A”为全选并复制快捷键,方便复制代码 | ||
8 | "4.按“F2”可以直接消除代码中的空行 | ||
9 | "5.“F3”可列出当前目录文件,打开树状文件目录 | ||
10 | "6. 支持鼠标选择、方向键移动 | ||
11 | "7. 代码高亮,自动缩进,显示行号,显示状态行 | ||
12 | "8. 按“Ctrl + P”可自动补全 | ||
13 | "9. []、{}、()、""、‘ ‘等都自动补全 --- 如果需要{}做函数形式的补全(右括号自动换行,加一个空行,光标定位到空行,可以看下面的修改提示) | ||
14 | "10. 使用YouCompleteMe提供C++的自动补全提示,效果类似 Visual Studio那种,可以解析系统头文件 | ||
15 | |||
16 | |||
17 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
18 | " """""""""""""" Suzzz """"""""""""""""""""" | ||
19 | "https://github.com/gmarik/Vundle.vim#about | ||
20 | |||
21 | set nocompatible " be iMproved, required | ||
22 | filetype off " required | ||
23 | |||
24 | set rtp+=~/.vim/bundle/Vundle.vim | ||
25 | |||
26 | call vundle#begin() | ||
27 | " let Vundle manage Vundle, required | ||
28 | Plugin "gmarik/Vundle.vim" | ||
29 | " plugin on GitHub repo 添加github上的vimn插件,形式非常简单 | ||
30 | Plugin "tpope/vim-fugitive" | ||
31 | "语法检查 | ||
32 | Plugin "scrooloose/syntastic" | ||
33 | "让 syntastic忽略 python 文件 | ||
34 | let g:syntastic_ignore_files=[".*\.py$"] | ||
35 | "补全 python | ||
36 | Plugin "davidhalter/jedi" | ||
37 | Plugin "rstacruz/sparkup", {"rtp": "vim/"} | ||
38 | " YouCompleteMe插件,很好的智能提示,基本达到 IDE 级别 | ||
39 | Plugin "Valloric/YouCompleteMe" | ||
40 | |||
41 | call vundle#end() " required | ||
42 | |||
43 | filetype plugin indent on " required | ||
44 | " To ignore plugin indent changes, instead use: | ||
45 | "filetype plugin on | ||
46 | " YouCompleteMe 通过这个cm_global_ycm_extra_conf来获得补全规则,可以如下指定,也可以每次放置在工作目录 | ||
47 | let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘ | ||
48 | "让YouCompleteMe同时利用原来的ctags | ||
49 | let g:ycm_collect_identifiers_from_tag_files = 1 | ||
50 | |||
51 | " """"""""""""" By ma6174 """"""""""""""""""""" | ||
52 | " 显示相关 | ||
53 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
54 | autocmd InsertLeave * se nocul " 用浅色高亮当前行 | ||
55 | autocmd InsertEnter * se cul " 用浅色高亮当前行 | ||
56 | "set ruler " 显示标尺 | ||
57 | set showcmd " 输入的命令显示出来,看的清楚些 | ||
58 | "set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议) | ||
59 | "set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | ||
60 | set novisualbell " 不要闪烁(不明白) | ||
61 | "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 | ||
62 | set laststatus=2 " 启动显示状态行(1),总是显示状态行(2) | ||
63 | "set foldenable " 允许折叠 | ||
64 | "set foldmethod=manual " 手动折叠 | ||
65 | "set background=dark "背景使用黑色 | ||
66 | " 显示中文帮助 | ||
67 | if version >= 603 | ||
68 | set helplang=cn | ||
69 | set encoding=utf-8 | ||
70 | endif | ||
71 | |||
72 | set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 | ||
73 | set termencoding=utf-8 | ||
74 | set encoding=utf-8 | ||
75 | set fileencodings=ucs-bom,utf-8,cp936 | ||
76 | set fileencoding=utf-8 | ||
77 | |||
78 | "键盘命令 | ||
79 | |||
80 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
81 | |||
82 | "map <C-A> ggVGY | ||
83 | "map! <C-A> <Esc>ggVGY | ||
84 | "map <F12> gg=G | ||
85 | ""去空行 | ||
86 | "nnoremap <F2> :g/^\s*$/d<CR> | ||
87 | |||
88 | "比较文件 | ||
89 | nnoremap <C-F2> :vert diffsplit | ||
90 | |||
91 | "列出当前目录文件 | ||
92 | map <F3> :tabnew .<CR> | ||
93 | |||
94 | "打开树状文件目录 | ||
95 | map <C-F3> \be | ||
96 | |||
97 | "C,C++ 按F5编译运行 | ||
98 | map <F5> :call CompileRunGcc()<CR> | ||
99 | |||
100 | func! CompileRunGcc() | ||
101 | |||
102 | exec "w" | ||
103 | if &filetype == ‘c‘ | ||
104 | exec "!g++ % -o %<" | ||
105 | exec "! ./%<" | ||
106 | elseif &filetype == ‘cpp‘ | ||
107 | exec "!g++ % -o %<" | ||
108 | exec "! ./%<" | ||
109 | elseif &filetype == ‘java‘ | ||
110 | exec "!javac %" | ||
111 | exec "!java %<" | ||
112 | elseif &filetype == ‘sh‘ | ||
113 | :!./% | ||
114 | endif | ||
115 | endfunc | ||
116 | |||
117 | "C,C++的调试 | ||
118 | |||
119 | map <F8> :call Rungdb()<CR> | ||
120 | |||
121 | func! Rungdb() | ||
122 | exec "w" | ||
123 | exec "!g++ % -g -o %<" | ||
124 | exec "!gdb ./%<" | ||
125 | endfunc | ||
126 | |||
127 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
128 | |||
129 | ""实用设置 | ||
130 | |||
131 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
132 | |||
133 | " 设置当文件被改动时自动载入 | ||
134 | set autoread | ||
135 | |||
136 | " quickfix模式 | ||
137 | autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr> | ||
138 | |||
139 | "代码补全 | ||
140 | set completeopt=preview,menu | ||
141 | |||
142 | "允许插件 | ||
143 | filetype plugin on | ||
144 | |||
145 | "共享剪贴板 | ||
146 | set clipboard+=unnamed | ||
147 | |||
148 | "从不备份 | ||
149 | "set nobackup | ||
150 | |||
151 | "make 运行 | ||
152 | :set makeprg=g++\ -Wall\ \ % | ||
153 | |||
154 | "自动保存 | ||
155 | set autowrite | ||
156 | |||
157 | set ruler " 打开状态栏标尺 | ||
158 | set cursorline " 突出显示当前行 | ||
159 | set magic " 设置魔术 | ||
160 | set guioptions-=T " 隐藏工具栏 | ||
161 | set guioptions-=m " 隐藏菜单栏 | ||
162 | " 设置在状态行显示的信息 | ||
163 | "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ | ||
164 | |||
165 | "set foldcolumn=0 | ||
166 | "set foldmethod=indent | ||
167 | "set foldlevel=3 | ||
168 | "set foldenable " 开始折叠 | ||
169 | |||
170 | " 去掉输入错误的提示声音 | ||
171 | set noeb | ||
172 | |||
173 | " 在处理未保存或只读文件的时候,弹出确认 | ||
174 | set confirm | ||
175 | |||
176 | " 自动缩进 | ||
177 | "set autoindent | ||
178 | "set cindent | ||
179 | |||
180 | " 在行和段开始处使用制表符 | ||
181 | set smarttab | ||
182 | |||
183 | " 历史记录数 | ||
184 | set history=1000 | ||
185 | |||
186 | "禁止生成临时文件 | ||
187 | set noswapfile | ||
188 | |||
189 | "搜索忽略大小写 | ||
190 | set ignorecase | ||
191 | |||
192 | "搜索逐字符高亮 | ||
193 | set hlsearch | ||
194 | set incsearch | ||
195 | |||
196 | "行内替换 | ||
197 | set gdefault | ||
198 | |||
199 | "语言设置 | ||
200 | set langmenu=zh_CN.UTF-8 | ||
201 | set helplang=cn | ||
202 | |||
203 | " 我的状态行显示的内容(包括文件类型和解码) | ||
204 | "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} | ||
205 | "set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] | ||
206 | |||
207 | " 总是显示状态行 | ||
208 | set laststatus=2 | ||
209 | |||
210 | " 命令行(在状态行下)的高度,默认为1,这里是2 | ||
211 | set cmdheight=2 | ||
212 | |||
213 | " 带有如下符号的单词不要被换行分割 | ||
214 | set iskeyword+=_,$,@,%,#,- | ||
215 | |||
216 | set selection=exclusive | ||
217 | set selectmode=mouse,key | ||
218 | |||
219 | " 通过使用: commands命令,告诉我们文件的哪一行被改变过 | ||
220 | set report=0 | ||
221 | |||
222 | " 光标移动到buffer的顶部和底部时保持3行距离 | ||
223 | set scrolloff=3 | ||
224 | |||
225 | " 为C程序提供自动缩进 | ||
226 | |||
227 | " 高亮显示普通txt文件(需要txt.vim脚本) | ||
228 | |||
229 | au BufRead,BufNewFile * setfiletype txt | ||
230 | |||
231 | "自动补全 | ||
232 | "by Suzzz: 原作者这种设置,输入{会自动补全,并且中间插入一个空行,将光标定位到空行。这对于函数是OK的,但是使用花括号初始化数组、vector时就不方便了。所以改为现在这种。只是补全,然后光标在左右括号中间。 | ||
233 | ":inoremap { {<CR>}<ESC>O | ||
234 | :inoremap ( ()<ESC>i | ||
235 | :inoremap ) <c-r>=ClosePair(‘)‘)<CR> | ||
236 | :inoremap { {}<ESC>i | ||
237 | :inoremap } <c-r>=ClosePair(‘}‘)<CR> | ||
238 | :inoremap [ []<ESC>i | ||
239 | :inoremap ] <c-r>=ClosePair(‘]‘)<CR> | ||
240 | :inoremap " ""<ESC>i | ||
241 | :inoremap ‘ ‘‘<ESC>i | ||
242 | |||
243 | function! ClosePair(char) | ||
244 | if getline(‘.‘)[col(‘.‘) - 1] == a:char | ||
245 | return "\<Right>" | ||
246 | else | ||
247 | return a:char | ||
248 | endif | ||
249 | endfunction | ||
250 | |||
251 | set completeopt=longest,menu | ||
252 | |||
253 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
254 | |||
255 | " CTags的设定 | ||
256 | |||
257 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
258 | |||
259 | let Tlist_Sort_Type = "name" " 按照名称排序 | ||
260 | let Tlist_Use_Right_Window = 1 " 在右侧显示窗口 | ||
261 | let Tlist_Compart_Format = 1 " 压缩方式 | ||
262 | let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer | ||
263 | let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags | ||
264 | let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树 | ||
265 | autocmd FileType java set tags+=D:\tools\java\tags | ||
266 | "autocmd FileType h,cpp,cc,c set tags+=D:\tools\cpp\tags | ||
267 | "let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的 | ||
268 | "设置tags | ||
269 | set tags=tags | ||
270 | "set autochdir | ||
271 | |||
272 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
273 | |||
274 | "其他东东 | ||
275 | |||
276 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
277 | |||
278 | "默认打开Taglist | ||
279 | let Tlist_Auto_Open=1 | ||
280 | |||
281 | """""""""""""""""""""""""""""" | ||
282 | |||
283 | " Tag list (ctags) | ||
284 | |||
285 | """""""""""""""""""""""""""""""" | ||
286 | |||
287 | let Tlist_Ctags_Cmd = ‘/usr/bin/ctags‘ | ||
288 | let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的 | ||
289 | let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim | ||
290 | let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口 | ||
291 | " minibufexpl插件的一般设置 | ||
292 | let g:miniBufExplMapWindowNavVim = 1 | ||
293 | let g:miniBufExplMapWindowNavArrows = 1 | ||
294 | let g:miniBufExplMapCTabSwitchBufs = 1 | ||
295 | let g:miniBufExplModSelTarget = 1 | ||