-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy path.vimrc
221 lines (172 loc) · 5.01 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
"------------------------------
" MacVim configuration settings
" author: gerryyang
" update time: 2019-07-08
"------------------------------
" -------------
" Vundle
" https://github.com/gmarik/Vundle.vim
" -------------
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
"set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
"Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
""Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
""Plugin 'L9'
" Git plugin not hosted on GitHub
""Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
""Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
""Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
""Plugin 'user/L9', {'name': 'newL9'}
" Install Vim-go
"Plugin 'fatih/vim-go'
" All of your Plugins must be added before the following line
"call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" -------------
" 基本设置
" -------------
" 启用vim高级特性(置于配置最前)
se nocompatible
" 设置文件编码
set encoding=utf-8
" for Linux
set fenc=utf-8
" for Windows
" set fenc=cp936
set fileencodings=ucs-bom,utf-8,cp936,gb2312,gb18030,big5
" 设置粘贴格式
set clipboard+=unnamed " use the clipboards of vim and win
set paste " Paste from a windows or from vim
set go+=a " Visual selection automatically copied to the clipboard
" 显示行号
se nu
" 设置默认字体
se guifont=Monaco:h14
" 设置默认窗口大小
se lines=35 columns=99
" 设置当前行高亮, cursorline
se cul
" 将当前光标下的列高亮, cursorcolumn
" 对于Pythoner比较有用
"se cuc
" 显示光标位置
se ruler
" 记录上次打开的位置
if has("autocmd")
autocmd BufRead *.txt set tw=78
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
" -------------
" 搜索设置
" -------------
" enable magic matching
set magic
" show matching bracets
set showmatch
" highlight search things
set hlsearch
" ignore case when searching
set smartcase
set ignorecase
" incremental match when searching
set incsearch
" -------------
" 代码设置
" -------------
" 设置语法高亮
syntax enable
syntax on
" 显示缩进tab线
se list lcs=tab:\|\
" 设置代码折叠
set foldenable
set foldnestmax=1
set foldmethod=syntax
" -------------
" 缩进设置
" -------------
" auto indent
set autoindent
" c indent
set cindent
" smart indet
set smartindent
" use hard tabs
set tabstop=4
" 将空格转换为tab, :%retab
set noexpandtab
set shiftwidth=4
" 自动换行
" break long lines
set textwidth=1000
" 设置某列高亮
"se cc=+1
" config C-indenting
set cinoptions=:0,l1,t0,g0
" enable filetype plugin
filetype plugin indent on
" use soft tabs for python
autocmd Filetype python set et sta ts=4 sw=4
" -------------
" 快捷键设置
" -------------
" format codes
map <F8> ggVG= <CR>
" open multiple files in tabs
map <F0> :tabedit <CR>
" ------ Tabular Plugin [beg] ------
" Tabular codes, '='
map <F1> :Tab/= <CR>
" Tabular codes, ','
map <F2> :Tab/,\zs <CR>
" Tabular codes, '<<'
map <F3> :Tab/<< <CR>
" it will call the :Tabularize command each time you insert a | character.
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
"if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
"endif
endfunction
" ------ Tabular Plugin [end] ------
" To insert timestamp, press F4
" 命令模式
nmap <F4> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
" 插入模式
imap <F4> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR>
" To save, press ctrl-s.
nmap <c-s> :w<CR>
imap <c-s> <Esc>:w<CR>a