-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrcbak
200 lines (167 loc) · 5.98 KB
/
vimrcbak
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 显示相关
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
syntax on " 语法高亮
" 在处理未保存或只读文件的时候,弹出确认
set confirm
" 设置代码折叠(按照缩进层级),zc折起,zo打开
set foldmethod=indent
" 自动缩进
set autoindent
set cindent
set smartindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 不要用空格代替制表符
set expandtab
" 在行和段开始处使用制表符
set smarttab
set smartcase
" 显示行号
set number
" 显示输入命令
set showcmd
"autocmd InsertLeave * set nocul " 浅色高亮当前行
"autocmd InsertEnter * set cul " 用浅色高亮当前行
"set ruler " 显示标尺
" 设置配色方案
let g:solarized_termcolors=256
"set background=dark
"colorscheme solarized
colorscheme elflord
"set background=light
"
set scrolloff=7 " 光标移动到buffer的顶部和底部时保持N行距离
set novisualbell " 不要闪烁
"编码方式
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936
set fileencoding=utf-8
:au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""实用设置"""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 设置当文件被改动时自动载入
set autoread
" quickfix模式
"autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
"代码补全
set completeopt=preview,menu
"允许插件
filetype plugin on
"共享剪贴板
set clipboard+=unnamed
"从不备份
"set nobackup
"自动保存
set autowrite
"搜索逐字符高亮
set hlsearch
set incsearch
" 总是显示状态行
set laststatus=1
" 命令行(在状态行下)的高度
set cmdheight=1
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,@,%,#,-
" 允许使用使用鼠标的模式(当前设置为可视模式)
if has('mouse')
set mouse=v
set selection=exclusive
set selectmode=mouse,key
endif
" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
" 侦测文件类型
filetype on
" 载入文件类型插件
filetype plugin on
" 为特定文件类型载入相关缩进文件
filetype indent on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""快速调试""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"列出当前目录文件
"map <F3> :tabnew .<CR>
"打开树状文件目录
"map <C-F3> \be
"python,shell,C,C++ 按F5编译运行
map <F5> :call CompileRunGcc()<CR>
nmap <leader>g :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
:!sh ./%
elseif &filetype == 'python'
:!python ./%|more
endif
endfunc
"C,C++的调试
map <F8> :call Rungdb()<CR>
func! Rungdb()
exec "w"
exec "!g++ % -g -o %<"
exec "!gdb ./%<"
endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""新文件标题""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype == 'sh' || &filetype == 'python'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: NLP_Team")
call append(line(".")+2, "\# Mail: [email protected]")
call append(line(".")+3, "\# Created Time: ".strftime("%T %F"))
call append(line(".")+4, "\#########################################################################")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: NLP_Team")
call append(line(".")+2, " > Mail: [email protected]")
call append(line(".")+3, " > Created Time: ".strftime("%T %F"))
call append(line(".")+4, " ************************************************************************/")
endif
if &filetype == 'sh'
call append(line(".")-1, "\#!/bin/bash")
call append(line(".")+6, "")
endif
if &filetype == 'python'
call append(line(".")-1, "\#-*- coding:UTF-8 -*-")
call append(line(".")-2, "\#!/usr/bin/env python")
call append(line(".")+5, "import sys")
call append(line(".")+6, "")
endif
if &filetype == 'cpp'
call append(line(".")+5, "#include<iostream>")
call append(line(".")+6, "using namespace std;")
call append(line(".")+7, "")
endif
if &filetype == 'c'
call append(line(".")+5, "#include<stdio.h>")
call append(line(".")+6, "")
endif
"新建文件后,自动定位到文件末尾
exe "normal G"
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""