-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
129 lines (103 loc) · 3.43 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
" 基础配置
syntax on
set encoding=utf-8
set nu
set ruler
" 自动缩进和Tabs设置
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
set cindent
set ai!
set smartindent
" 基于缩进进行代码折叠
set foldmethod=manual
" 启动 Vim 时关闭折叠
set nofoldenable
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" 符号自动匹配
set showmatch
" 搜索自动匹配
set incsearch
filetype plugin on
"F5运行python3
map <F5> :call RunPython()<CR>
func! RunPython()
exec "W"
if &filetype == 'python'
exec "!time python3 %"
endif
endfunc
map <C-r> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "cd %:p:h"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'sh'
:!./%
endif
endfunc
" shell、python头文件
autocmd BufNewFile *.py,*.sh exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
let filetype_name = strpart(expand("%"), stridx(expand("%"), "."))
if filetype_name == '.sh'
call setline(1,"\#!/bin/bash")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: xxx")
call append(line(".")+2, "\# mail: [email protected]")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "")
elseif filetype_name == '.py'
call setline(1,"#!/usr/bin/python3")
call append(line("."), "# -*- coding:utf-8 -*-")
call append(line(".")+1, "\# File Name: ".expand("%"))
call append(line(".")+2, "\# Author: xxx")
call append(line(".")+3, "\# Mail: [email protected] ")
call append(line(".")+4, "\# Created Time: ".strftime("%c"))
call append(line(".")+6,"")
else
call setline(1, "/*************************************************************************")
call append(line("."), " File Name: ".expand("%"))
call append(line(".")+1, "Author: xxx")
call append(line(".")+2, " Mail: [email protected] ")
call append(line(".")+3, " Created Time: ".strftime("%c"))
call append(line(".")+5, "")
endif
"新建文件后,自动定位到文件末尾
endfunc
autocmd BufNewFile * normal G
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
Plug 'mhinz/vim-startify'
Plug 'airblade/vim-gitgutter'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tell-k/vim-autopep8'
autocmd FileType python noremap <buffer> <F8> :call Autopep8()<CR>
Plug 'Raimondi/delimitMate'
Plug 'maralla/completor.vim'
let g:completor_python_binary = '/usr/bin/python3'
Plug 'vim-syntastic/syntastic'
Plug 'scrooloose/nerdtree'
map <C-n> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'Yggdroot/indentLine'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
" Initialize plugin system
call plug#end()