-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
275 lines (216 loc) · 5.91 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
"""""""""""""""""""""""""""""""""""""""""
"
" CtrlP
"
""""""""""""""""""""""""""""""""""""""""
let g:ctrlp_map = ',,'
let g:ctrlp_open_multiple_files = 'v'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git)$',
\ 'file': '\v\.(log|jpg|png|jpeg)$',
\ }
""""""""""""""""""""""""""""""""""""""""
"
" auto-save
"
""""""""""""""""""""""""""""""""""""""""
let g:auto_save = 1
"""""""""""""""""""""""""""""""""""""""""
"
" tComment
"
""""""""""""""""""""""""""""""""""""""""
" Use Ctrl-c to comment and uncomment, cool
map <c-c> gcc
"""""""""""""""""""""""""""""""""""""""""
"
" rails.vim
"
""""""""""""""""""""""""""""""""""""""""
" I don't use Rcontroller... stuff a lot
" cause I have CtrlP, but rails.vim provide me `gf` for rails projects
""""""""""""""""""""""""""""""""""""""""
"
" for Mac
"
""""""""""""""""""""""""""""""""""""""""
" vim run in Mac terminal, does not have syntax highlighting without this
syntax on
""""""""""""""""""""""""""""""""""""""""
"
" for markdown
"
""""""""""""""""""""""""""""""""""""""""
" when you have .md file, default ft=modula2, thus wrong highlighting
autocmd FileType modula2 set ft=
""""""""""""""""""""""""""""""""""""""""
"
" pathogen
"
""""""""""""""""""""""""""""""""""""""""
" doorkeeper of all my vim plugins
call pathogen#infect()
""""""""""""""""""""""""""""""""""""""""
"
" ack
"
""""""""""""""""""""""""""""""""""""""""
" sudo apt-get install ack-grep, on ubuntu box
map ,k :Ack <cword><ENTER>
""""""""""""""""""""""""""""""""""""""""
"
" EOL whitespace
"
""""""""""""""""""""""""""""""""""""""""
" now if you have spaces at end of lines, you get notified
set list
set listchars=trail:+
""""""""""""""""""""""""""""""""""""""""
"
" paste
"
""""""""""""""""""""""""""""""""""""""""
" for insert mode
set pastetoggle=<f2>
""""""""""""""""""""""""""""""""""""""""
"
" filetype
"
""""""""""""""""""""""""""""""""""""""""
" Enable filetype plugin
" for i_Ctrl-X_Ctrl-O
filetype plugin on
""""""""""""""""""""""""""""""""""""""""
"
" indent
"
""""""""""""""""""""""""""""""""""""""""
" check :h filetype-indent-on
" have proper indent level based on syntax
" `=` also depends on this to work
filetype indent on
" if you use <tab> to indent the code
" vim use tabs other than spaces for the indentaion
" expandtab will turn a tab into 'tabstop' spaces
set expandtab
set tabstop=2
" if you use '>' or <c-t> to indent the code, this matters
" this default to 8
set shiftwidth=2
" you can also set different indent level for other languages
autocmd FileType c setlocal shiftwidth=4 tabstop=4
""""""""""""""""""""""""""""""""""""""""
"
" buffers
"
""""""""""""""""""""""""""""""""""""""""
set hidden "in order to switch between buffers with unsaved change
map <s-tab> :bp<cr>
map <tab> :bn<cr>
map ,bd :bd<cr>
""""""""""""""""""""""""""""""""""""""""
"
" why I use *,* to do mapping?
"
""""""""""""""""""""""""""""""""""""""""
" inspired by Derek, the reasons:
" 1. <LEADER> is too long to type
" 2. *,* is easier to reach than *\*
" 3. in practice you nerver type in *,v*, but *, v*
" Derek also do a nomap for *,*
" nnomap <c-e> ,
" I do not do it, since I do not use *,* as a command a lot
""""""""""""""""""""""""""""""""""""""""
"
" quit quickly
"
""""""""""""""""""""""""""""""""""""""""
map ,f :q!<CR>
""""""""""""""""""""""""""""""""""""""""
"
" vimrc editing
"
""""""""""""""""""""""""""""""""""""""""
" I need a fake ~/.vimrc: runtime vimrc
" http://www.derekwyatt.org/vim/the-vimrc-file/my-vimrc-file/
map ,e :e ~/.vim/vimrc<CR>
" When vimrc is edited, reload it
" copied from http://amix.dk/vim/vimrc.html
autocmd! bufwritepost vimrc source ~/.vim/vimrc
""""""""""""""""""""""""""""""""""""""""
"
" quick escape
"
""""""""""""""""""""""""""""""""""""""""
" set quick escape from insert mode, and now I can go without arrow keys and
" use j and k to move around in insert mode
imap jj <esc>
""""""""""""""""""""""""""""""""""""""""
"
" wildmode
"
""""""""""""""""""""""""""""""""""""""""
" use <C-D> with this to get a list
set wildmenu
""""""""""""""""""""""""""""""""""""""""
"
" dictionary
"
""""""""""""""""""""""""""""""""""""""
" i_CTRL_X_K
set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
""""""""""""""""""""""""""""""""""""""""
"
" Search
"
""""""""""""""""""""""""""""""""""""""""
" ic also has effect on dictionary settings
set ic
"set hlsearch
set incsearch
""""""""""""""""""""""""""""""""""""""""
"
" status line
"
""""""""""""""""""""""""""""""""""""""""
" Set the status line the way i like it
set statusline=%F:\ %l
" tell VIM to always put a status line in, even if there is only one window
" this means I can also see what is the filename I am in, finally!
set laststatus=2
""""""""""""""""""""""""""""""""""""""""
"
" misc
"
""""""""""""""""""""""""""""""""""""""""
" have nice $ sign when you use `cw`
set cpoptions+=$
" Do not know how to use autocmd yet, so the following line not working
" autocmd FileType text setlocal textwidth=78
set textwidth=78
" get rid of the silly characters in window separators
set fillchars=""
" hello-world is now one world
set isk+=-
" change cwd to current buffer
nmap <silent> ,cd :lcd %:h<CR>
let g:neocomplcache_enable_at_startup = 1
let g:lightline = {
\ 'colorscheme': 'landscape',
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'filename', 'modified', 'anzu']
\ ]
\ },
\ 'component_function': {
\ 'anzu': 'anzu#search_status'
\ }
\ }
"}}}"
if !has('gui_running')
set t_Co=256
endif
set cursorline
set number