总有些东西需要存

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
"filetype plugin on
"filetype plugin indent on
filetype off
"自动缩进的空格数
set shiftwidth=4
"关闭vi兼容模式
set nocompatible
"显示行号
set number
"打开状态栏标尺
set ruler
"退格键删除四个空格
set softtabstop=4
"tab长度为4
set tabstop=4
set expandtab
"设置自动缩进
set autoindent
"覆盖文件时不备份
set nobackup
" 禁止生成临时文件
set noswapfile
"搜索时忽略大小写
set ignorecase smartcase
"输入内容时开始搜索
set incsearch
"高亮显示搜索结果
set hlsearch
"关闭错误信息响铃
set noerrorbells
"关闭使用可视响铃代替呼叫
set novisualbell
"置空错误铃声的终端代码
set t_vb=
"set showmatch " 插入括号时,短暂地跳转到匹配的对应括号
"set matchtime=2 " 短暂跳转到匹配括号的时间
"设置魔术
set magic
"开启新行时使用智能自动缩进
set smartindent
"不设定在插入状态无法用退格键和 Delete 键删除回车符
set backspace=indent,eol,start
"显示状态栏 (默认值为 1, 无法显示状态栏)
set laststatus=2
"设定命令行的行数为 1
set cmdheight=1
"高亮显示匹配的括号
set showmatch
"匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5
"与windows贡献剪切板
set clipboard+=unnamed
"文件类型检测
filetype on
"不同文件类型采用不同缩进
filetype indent on
"语法高亮
syntax on
"粘贴时保持格式
"set paste
"设定默认解码
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
"设定编码
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message en_US.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

" 状态栏配置
function! File_size(f)
let l:size = getfsize(expand(a:f))
if l:size == 0 || l:size == -1 || l:size == -2
return ''
endif
if l:size < 1024
return l:size.' bytes'
elseif l:size < 1024*1024
return printf('%.1f', l:size/1024.0).'KB'
elseif l:size < 1024*1024*1024
return printf('%.1f', l:size/1024.0/1024.0) . 'MB'
else
return printf('%.1f', l:size/1024.0/1024.0/1024.0) . 'GB'
endif
endfunction
set statusline=%F%m%r%h%w\ [%{&ff}]\ [%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v,%p%%]\ [LEN=%L]\ [%{File_size(@%)}]\ [%{''.(&fenc!=''?&fenc:&enc).''}]

" 新建py文件时自动添加头部
autocmd BufNewFile *py exec ":call NewPython()"

function! NewPython()
call setline(1,"# -*- coding:utf-8 -*-")
call append(line(".")," ")
call append(line(".")+1,"# Author dream10201")
call append(line(".")+2,"# E-mail 201269807@qq.cmom")
call append(line(".")+3,"# Created Time ".strftime("%Y/%m/%d %H:%M:%S",localtime()))
call append(line(".")+4,"")
endfunction

" markdown头部
autocmd BufNewFile *md exec ":call NewMarkDown()"

" http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers
function! NewMarkDown()
call setline(1,"---")
call append(line("."),"title: ".expand("%:t:r"))
call append(line(".")+1,"tags:")
call append(line(".")+2," - ")
call append(line(".")+3,"categories:")
call append(line(".")+4," - ")
call append(line(".")+5,"date: ".strftime("%Y/%m/%d %H:%M:%S",localtime()))
call append(line(".")+6,"updated: ".strftime("%Y/%m/%d %H:%M:%S",localtime()))
call append(line(".")+7,"permalink: ".strftime("%Y%m%d%H%M%S",localtime()))
call append(line(".")+8,"---")
call append(line(".")+9,"")
call append(line(".")+10,"<!--more-->")
endfunction

" 新建文件后自动定位到末尾
autocmd BufNewFile * normal G

"插入当前时间
inoremap <C-d> <c-r>=strftime("%Y/%m/%d %H:%M:%S")<cr>
"set completeopt-=preview
set completeopt=longest,menu
let g:ycm_server_python_interpreter='/usr/bin/python3.5'
let g:ycm_global_ycm_extra_conf='/root/.vim/plugin/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
" 检查.ycm_extra_conf.py提示
let g:ycm_confirm_extra_conf=0
" 键入字符个数提示
let g:ycm_min_num_of_chars_for_completion=2
" 移动时提示
let g:ycm_echo_current_diagnostic=0
"关键字补全
let g:ycm_seed_identifiers_with_syntax=1
"YCM标签引擎
let g:ycm_collect_identifiers_from_tags_files=1
" 字符串补全
let g:ycm_complete_in_strings=1
" 语法提示
let g:ycm_show_diagnostics_ui=1
" 注释中输入补全
let g:ycm_complete_in_comments=1
" 注释和字符串中的文字用于提示
let g:ycm_collect_identifiers_from_comments_and_strings=1
" 显示预览窗口
let g:ycm_add_preview_to_completeopt=1
" 选择选项后关闭预览窗口
let g:ycm_autoclose_preview_window_after_completion=1
" 退出插入模式后关闭预览窗口
let g:ycm_autoclose_preview_window_after_insertion=1
" 关闭提示快捷键
let g:ycm_key_list_stop_completion=['<Left>','<Right>']