-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
171 lines (161 loc) · 4.93 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
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
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" 关于taglist
"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
" 去掉vi一致性
set nocompatible
"解决中文乱码
"let &termencoding=&encoding
"set fileencodings=utf-8,gb2312,gbk,gb18030,ucs-bom,cp936
"编码设置
set encoding=utf-8
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
let &termencoding=&encoding
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" 新添加的配置参数
set mouse=a
syntax on
set cmdheight=3
set autowrite
set number
set showcmd
"set lcs=tab:>-,trail:-
"set list
set showmode
set title
set ruler
set encoding=utf-8
set fileencoding=utf-8
set nobackup
"set expandtab
set shiftwidth=4
set smarttab
set fdm=manual
set fdc=4
set wrap
set hlsearch
set incsearch
" 设置行号
set number
" 检测文件类型
filetype on
filetype plugin on
filetype indent on
" 记录历史的行数
set history=500
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
"autocmd VimEnter * NERDTree
"autocmd BufEnter * NERDTreeMirror
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
" 背景为黑色
set background=dark
" 自动对齐
set autoindent
" 智能自动对齐
set smartindent
" 缩进
set tabstop=4
set shiftwidth=4
" 匹配模式
set showmatch
" 去除vim的GUI版本的toolbar
set guioptions-=T
" 显示光标所在位置
set ruler
" 快速找到答案
set incsearch
" 自动补全
" inoremap ( ()
" inoremap { {}
" inoremap "
" inoremap < <>
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
"
" 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
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"进行版权声明的设置
""添加或更新头
map <F4> :call TitleDet()<cr>'s
function AddTitle()
call append(0,"/*============================================================================")
call append(1,"# Author: Wade Leng")
call append(2,"# E-mail: [email protected]")
call append(3,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(4,"# Filename: ".expand("%:t"))
call append(5,"# Description: ")
call append(6,"============================================================================*/")
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf
"更新最近修改时间和文件名
function UpdateTitle()
normal m'
execute '/# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@'
normal ''
normal mk
execute '/# *Filename:/s@:.*$@\=":\t\t".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()
let n=1
"默认为添加
while n < 7
let line = getline(n)
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction