-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.vimrc
More file actions
352 lines (269 loc) · 10.1 KB
/
vimrc.vimrc
File metadata and controls
352 lines (269 loc) · 10.1 KB
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
"
" .vimrc
"
" Put together from scratch
" By mattbo
" 8/26/08
"
" Based loosely on Smylers's .vimrc
" http://www.stripey.com/vim/vimrc.html
"
" first, clear any existing autocommands:
autocmd!
" Next, turn off Vi compatibility mode!
set nocompatible
" Set up Vundle. Must come before filetype detection!
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
" let Vundle manage Vundle (required)
Plugin 'gmarik/Vundle.vim'
"My Bundles
"From github
" Surround text with things like " or >
Plugin 'tpope/vim-surround'
" Syntax checking plugin
Plugin 'scrooloose/syntastic'
" Text completion
Plugin 'shougo/neocomplete'
" Good syntax colors
Plugin 'altercation/vim-colors-solarized'
" Replace 'f' with two character version.
"Plugin 'goldfeld/vim-seek'
"From vim-scripts github account
"Plugin 'FuzzyFinder'
Plugin 'vim-scripts/SQLUtilities'
Plugin 'vim-scripts/django.vim'
Plugin 'lepture/vim-jinja'
"Other (non-github) repos
"Plugin 'git://git.wincent.com/command-t.git'
" These two are required by Vundle
call vundle#end()
filetype plugin indent on
" End Vundle config
" See the end of this file for bundle-specific configuration
" enable filetype detection:
filetype on
filetype plugin on
filetype indent on
""""
" Terminal settings
""""
" `XTerm', `RXVT', `Gnome Terminal', and `Konsole' all claim to be "xterm";
" `KVT' claims to be "xterm-color":
if &term =~ 'xterm'
" `Gnome Terminal' fortunately sets $COLORTERM; it needs <BkSpc> and <Del>
" fixing, and it has a bug which causes spurious "c"s to appear, which can be
" fixed by unsetting t_RV:
if $COLORTERM == 'gnome-terminal'
execute 'set t_kb=' . nr2char(8)
" [Char 8 is <Ctrl>+H.]
fixdel
set t_RV=
" Apple's Terminal sets TERM_PROGRAM to Apple_Terminal. No fixes are
" required
elseif $TERM_PROGRAM == 'Apple_Terminal'
elseif $TERM_PROGRAM == 'iTerm.app'
" `XTerm', `Konsole', and `KVT' all also need <BkSpc> and <Del> fixing;
" there's no easy way of distinguishing these terminals from other things
" that claim to be "xterm", but `RXVT' sets $COLORTERM to "rxvt" and these
" don't:
elseif $COLORTERM == ''
execute 'set t_kb=' . nr2char(8)
fixdel
" The above won't work if an `XTerm' or `KVT' is started from within a `Gnome
" Terminal' or an `RXVT': the $COLORTERM setting will propagate; it's always
" OK with `Konsole' which explicitly sets $COLORTERM to "".
endif
endif
" Finally, deal with screen. Screen sets $TERM = 'screen'. Set it back to
" xterm and things start working right...
if &term =~ 'screen'
set term=xterm
endif
" Set backspace to kill anything in insert mode
set bs=indent,eol,start
" change the termcap settings so titlestring affects the tab title
set t_ts=]1;
set title
autocmd BufReadPost * :set titlestring=%t
""""
" User Interface
""""
" Full python syntax highlighting
let python_highlight_all=1
" have syntax highlighting in terminals which can display colours:
if has('syntax') && (&t_Co > 2)
syntax on
endif
" have fifty lines of command-line (etc) history:
set history=50
" remember all of these between sessions, but only 10 search terms; also
" remember info for 10 files, but never any on removable disks, don't remember
" marks in files, don't rehighlight old search patterns, and only save up to
" 100 lines of registers; including @10 in there should restrict input buffer
" but it causes an error for me:
set viminfo=/10,'10,r/mnt/zip,r/mnt/floppy,f0,h,\"100
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full
" use "[RO]" for "[readonly]" to save space in the message line:
set shortmess+=r
" display the current mode, partially-typed commands, and the cursor position
" in the status line:
set showmode
set showcmd
" status line fanciness
" :help statusline for the full list of madness
set laststatus=2
set statusline= " clear the statusline for when vimrc is reloaded
"set statusline+=%f\ " file name
set statusline+=%-.30F\ " full path (w/ filename)
set statusline+=%n\ " buffer number
"set statusline+=%h " help flag(redundant w/filetype)
set statusline+=%m%r%w " flags (modified, RO, preview)
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
set statusline+=%{synIDattr(synID(line('.'),col('.'),1),'name')}\ " highlight
"set statusline+=%b,0x%-8B\ " current char (ascii decimal/hex)
set statusline+=%-14.(%l,%c%V%)\ %<%P " line, column, virt col percent
" when using list, keep tabs at their full width and display `arrows':
execute 'set listchars+=tab:' . nr2char(187) . nr2char(183)
" (Character 187 is a right double-chevron, and 183 a mid-dot.)
" don't have files trying to override this .vimrc:
set nomodeline
" * Text Formatting -- General
" don't make it look like there are line breaks where there aren't:
"set nowrap
" use indents of 4 spaces, and have them copied down lines:
set shiftwidth=4
set shiftround
set expandtab
set autoindent
set tabstop=4
"MSB let's be positive and set formatoptions...
":help fo-table to see a full listing of available options
set formatoptions=qc
set textwidth=80
" Wildmenus
:set wildmenu
" * Text Formatting -- Specific File Formats
" recognize everything with a .txt extension as being human-language text
" [this clobbers the `help' filetype, but that doesn't seem to prevent help from
" working properly]:
augroup filetype
autocmd BufNewFile,BufRead *.txt set filetype=human
augroup END
" treat lines starting with a quote mark as comments (for `Vim' files, such as
" this very one!), and colons as well so that reformatting usenet messages from
" `Tin' users works OK:
au FileType vim set comments+=b:\"
" in human-language files, automatically format everything at 72 chars:
autocmd FileType mail,human set formatoptions+=t textwidth=72
" for Perl programming, have things in braces indenting themselves:
autocmd FileType perl set smartindent
" for CSS, also have things in braces indented:
autocmd FileType css set smartindent
" for HTML, generally format text, but if a long line has been created leave it
" alone when editing:
autocmd FileType html set formatoptions=qlc
" for both CSS and HTML, use two spaces for tabs to make
" files a few bytes smaller:
autocmd FileType html,css set expandtab tabstop=2
" * Search & Replace
" make searches case-insensitive, unless they contain upper-case letters:
set ignorecase
set smartcase
" show the `best match so far' as search strings are typed:
set incsearch
" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault
" * Keystrokes -- Moving Around
" have the h and l cursor keys wrap between lines (like <Space> and <BkSpc> do
" by default), and ~ convert case over line breaks; also have the cursor keys
" wrap in insert mode:
set whichwrap=h,l,~,[,]
" use <Ctrl>+N/<Ctrl>+P to cycle through files:
nnoremap <C-N> :next<CR>
nnoremap <C-P> :prev<CR>
" [<Ctrl>+N by default is like j, and <Ctrl>+P like k.]
" have % bounce between angled brackets, as well as t'other kinds:
set matchpairs+=<:>
" have <F1> prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap <F1> :help<Space>
vmap <F1> <C-C><F1>
omap <F1> <C-C><F1>
map! <F1> <C-C><F1>
" * Keystrokes -- Formatting
" have Q reformat the current paragraph (or selected text if there is any):
nnoremap Q gqap
vnoremap Q gq
" have the usual indentation keystrokes still work in visual mode:
vnoremap <C-T> >
vnoremap <C-D> <LT>
vmap <Tab> <C-T>
vmap <S-Tab> <C-D>
" have Y behave analogously to D and C rather than to dd and cc (which is
" already done by yy):
noremap Y y$
" * Keystrokes -- Toggles
" Keystrokes to toggle options are defined here. They are all set to normal
" mode keystrokes beginning \t but some function keys (which won't work in all
" terminals) are also mapped.
" have \tp ("toggle paste") toggle paste on/off and report the change, and
" where possible also have <F4> do this both in normal and insert mode:
nnoremap \tp :set invpaste paste?<CR>
nmap <F4> \tp
imap <F4> <C-O>\tp
set pastetoggle=<F4>
" have \tf ("toggle format") toggle the automatic insertion of line breaks
" during typing and report the change:
nnoremap \tf :if &fo =~ 't' <Bar> set fo-=t <Bar> else <Bar> set fo+=t <Bar>
\ endif <Bar> set fo?<CR>
nmap <F3> \tf
imap <F3> <C-O>\tf
" have \tl ("toggle list") toggle list on/off and report the change:
nnoremap \tl :set invlist list?<CR>
nmap <F2> \tl
" have \th ("toggle highlight") toggle highlighting of search matches, and
" report the change:
nnoremap \th :set invhls hls?<CR>
" * Keystrokes -- Insert Mode
" allow <BkSpc> to delete line breaks, beyond the start of the current
" insertion, and over indentations:
set backspace=eol,start,indent
" have <Tab> (and <Shift>+<Tab> where it works) change the level of
" indentation:
inoremap <Tab> <C-T>
inoremap <S-Tab> <C-D>
" [<Ctrl>+V <Tab> still inserts an actual tab character.]
" end of Smylers's .vimrc
"
" External .vim files
" Specific to Python and C
source $HOME/.vim/PyC.vim
" Django html filetype autodetect
source $HOME/.vim/django.vim
set t_Co=256 "force vim to use 256 colors
if $ITERM_PROFILE == 'Solarized - Light' "react to Iterm profile
set background=light
else
set background=dark
endif
colorscheme solarized
" Settings specific to the bundles loaded at the top
" Syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = { "passive_filetypes": ["sql"]}
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_javascript_checkers = ['jshint', 'jslint']
let g:syntastic_javascript_jslint_args = "--nomen --regexp --plusplus --bitwise --newcap --sloppy --vars --browser --predef='$'"
" NeoComplete
source $HOME/.vim/neocomplete.vim