-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc2
216 lines (180 loc) · 5.92 KB
/
vimrc2
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
"behave mswin
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugin
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" 自动命令
" 读文件时自动设定当前目录为刚读入文件所在的目录
autocmd BufReadPost * cd %:p:h
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/vim/vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/vim/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curors - when moving vertical..
"set so=7
"set wildmenu "Turn on WiLd menu
set ruler "Always show current position
set nu
set cmdheight=2 "The commandbar height
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
"set statusline=%F%m%r,%Y,%{&fileformat}\ \ ASCII=\%b,HEX=\%B\ \ %l,%c\ %p%%\ \ [\ %L\ lines\ in\ all\ ]
set statusline=%Y,%{&fileformat}\ \ ASCII=\%b,HEX=\%B\ \ %l,%c\ %p%%\ \ [\ %L\ lines\ in\ all\ ]
" 设置在状态行显示的信息如下:
" %F 当前文件名
" %m 当前文件修改状态
" %r 当前文件是否只读
" %Y 当前文件类型
" %{&fileformat}
" 当前文件编码
" %b 当前光标处字符的 ASCII 码值
" %B 当前光标处字符的十六进制值
" %l 当前光标行号
" %c 当前光标列号
" %V 当前光标虚拟列号 (根据字符所占字节数计算)
" %p 当前行占总行数的百分比
" %% 百分号
" %L 当前文件总行数
"set hid "Change buffer - without saving
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
" Set font according to system
if MySys() == "mac"
set gfn=Menlo:h14
set shell=/bin/bash
elseif MySys() == "windows"
set guifont=Courier_New:h12:cANSI
"set guifontwide=Microsoft_YaHei_Mono:h12:cGB2312
"set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
set gfn=Monospace\ 10
set shell=/bin/bash
endif
if has("gui_running")
set guioptions-=T
set t_Co=256
set background=dark
"colorscheme peaksea
"colorscheme freya
colorscheme desert
else
colorscheme zellner
set background=dark
set nonu
endif
"set encoding=utf8
"try
" lang en_US
"catch
"endtry
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,sjis,euc-kr,ucs-2le,latin1
"set termencoding=cp936
set fileencoding=utf-8
"set ffs=unix,dos,mac "Default file types
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowritebackup
set noswapfile
"Persistent undo
"try
" if MySys() == "windows"
" set undodir=C:\Windows\Temp
" else
" set undodir=~/.vim_runtime/undodir
" endif
"
" set undofile
"catch
"endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab " 将 tab 键转换为空格
set shiftwidth=4
set tabstop=4
set smarttab
set lbr " linebreak
set tw=500
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
"""""""""""""""""""""""""""""""
"" => Visual mode related
"""""""""""""""""""""""""""""""
"" Really useful!
"" In visual mode when you press * or # to search for the current selection
"vnoremap <silent> * :call VisualSearch('f')<CR>
"vnoremap <silent> # :call VisualSearch('b')<CR>
"
"" When you press gv you vimgrep after the selected text
"vnoremap <silent> gv :call VisualSearch('gv')<CR>
"map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
"
"
"function! CmdLine(str)
" exe "menu Foo.Bar :" . a:str
" emenu Foo.Bar
" unmenu Foo
"endfunction
"
"" From an idea by Michael Naumann
"function! VisualSearch(direction) range
" let l:saved_reg = @"
" execute "normal! vgvy"
"
" let l:pattern = escape(@", '\\/.*$^~[]')
" let l:pattern = substitute(l:pattern, "\n$", "", "")
"
" if a:direction == 'b'
" execute "normal ?" . l:pattern . "^M"
" elseif a:direction == 'gv'
" call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
" elseif a:direction == 'f'
" execute "normal /" . l:pattern . "^M"
" endif
"
" let @/ = l:pattern
" let @" = l:saved_reg
"endfunction
""""""""""""""""""""""""""""""
" => bufExplorer plugin
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
map <leader>o :BufExplorer<cr>