-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
290 lines (215 loc) · 9.36 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
" -----------------------------------------------------------------------------
" | VIM Settings |
" | (see gvimrc for gui vim settings) |
" -----------------------------------------------------------------------------
set nocompatible
" Tabs ************************************************************************
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab
set sta " a <Tab> in an indent inserts 'shiftwidth' spaces
" Indenting ********************************************************************
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)
" Scrollbars ******************************************************************
set sidescrolloff=2
set numberwidth=4
" Windows *********************************************************************
set equalalways " Multiple windows, when created, are equal in size
set splitbelow splitright
"Vertical split then hop to new buffer
:noremap ,v :vsp^M^W^W<cr>
:noremap ,h :split^M^W^W<cr>
" Cursor highlights ***********************************************************
set cursorline
"set cursorcolumn
" Searching *******************************************************************
set hlsearch " highlight search
set incsearch " incremental search, search as you type
set ignorecase " Ignore case when searching
set smartcase " Ignore case when searching lowercase
" Colors **********************************************************************
"set t_Co=256 " 256 colors
set background=dark
syntax on " syntax highlighting
colorscheme baycomb
" Status Line *****************************************************************
set showcmd
set ruler " Show ruler
"set ch=2 " Make command line two lines high
" Line Wrapping ***************************************************************
set nowrap
set linebreak " Wrap at word
" Mappings ********************************************************************
" Professor VIM says '87% of users prefer jj over esc', jj abrams strongly disagrees
imap jj <Esc>
imap uu _
imap hh =>
imap aa @
" Directories *****************************************************************
" Setup backup location and enable
"set backupdir=~/backup/vim
"set backup
" Set Swap directory
"set directory=~/backup/vim/swap
" Sets path to directory buffer was loaded from
"autocmd BufEnter * lcd %:p:h
" File Stuff ******************************************************************
filetype plugin indent on
" To show current filetype use: set filetype
autocmd FileType html :set filetype=xhtml " we couldn't care less about html
" Inser New Line **************************************************************
map <S-Enter> O<ESC> " awesome, inserts new line without going into insert mode
map <Enter> o<ESC>
set fo-=r " do not insert a comment leader after an enter, (no work, fix!!)
" Sessions ********************************************************************
" Sets what is saved when you save a session
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
" Misc ************************************************************************
set backspace=indent,eol,start
set number " Show line numbers
set matchpairs+=<:>
set vb t_vb= " Turn off the bell, this could be more annoying, but I'm not sure how
" Set list Chars - for showing characters that are not
" normally displayed i.e. whitespace, tabs, EOL
"set listchars=trail:.,tab:>-,eol:$
"set nolist
" Mouse ***********************************************************************
"set mouse=a " Enable the mouse
"behave xterm
"set selectmode=mouse
" Cursor Movement *************************************************************
" Make cursor move by visual lines instead of file lines (when wrapping)
map <up> gk
map k gk
imap <up> <C-o>gk
map <down> gj
map j gj
imap <down> <C-o>gj
map E ge
" Ruby stuff ******************************************************************
"compiler ruby " Enable compiler support for ruby
"map <F5> :!ruby %<CR>
" Omni Completion *************************************************************
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete " may require ruby compiled in
" -----------------------------------------------------------------------------
" | Pluggins |
" -----------------------------------------------------------------------------
" SnippetsEmu *****************************************************************
"imap <unique> <C-j> <Plug>Jumper
"let g:snip_start_tag = "_\."
"let g:snip_end_tag = "\._"
"let g:snip_elem_delim = ":"
"let g:snip_set_textmate_cp = '1' " Tab to expand snippets, not automatically.
" fuzzyfinder_textmate *****************************************************************
map ,f :FuzzyFinderTextMate<CR>
map ,b :FuzzyFinderBuffer<CR>
"let g:fuzzy_ignore = '.o;.obj;.bak;.exe;.pyc;.pyo;.DS_Store;.db'
" Fuzzyfinder *****************************************************************
" Fuzzy finder rocks, like Command-T in TextMate (buggy at moment, fix!!)
"let g:FuzzyFinderOptions = { 'Base':{}, 'Buffer':{}, 'File':{}, 'MruFile':{}, 'FavFile':{}, 'Dir':{}, 'Tag':{}, 'TaggedFile':{}}
"let gf:FuzzyFinderOptions.Base.abbrev_map = { "^Project-" : ["**/"], }
"let g:FuzzyFinderOptions.Base.migemo_support = 0
"let g:FuzzyFinderOptions.File.excluded_path = '\v\~$|\.o$|\.git/|\.DS_Store|\.exe$|\.bak$|\.swp$|((^|[/\\])\.[/\\]$)'
"map ,f :FuzzyFinderFile Project-<CR>
"map ,b :FuzzyFinderBuffer<CR>
" autocomplpop ***************************************************************
" complete option
"set complete=.,w,b,u,t,k
"let g:AutoComplPop_CompleteOption = '.,w,b,u,t,k'
"set complete=.
let g:AutoComplPop_IgnoreCaseOption = 0
let g:AutoComplPop_BehaviorKeywordLength = 2
" -----------------------------------------------------------------------------
" | OS Specific |
" | (GUI stuff goes in gvimrc) |
" -----------------------------------------------------------------------------
" Mac *************************************************************************
"if has("mac")
""
"endif
" Windows *********************************************************************
"if has("gui_win32")
""
"endif
" -----------------------------------------------------------------------------
" | Test Stuff |
" -----------------------------------------------------------------------------
"" http://vim.wikia.com/wiki/Get_the_correct_indent_for_new_lines_despite_blank_lines
"function! IndentIgnoringBlanks(child)
"while v:lnum > 1 && getline(v:lnum-1) == ""
"normal k
"let v:lnum = v:lnum - 1
"endwhile
"if a:child == ""
"if v:lnum <= 1 || ! &autoindent
"return 0
"elseif &cindent
"return cindent(v:lnum)
"else
"return indent(v:lnum-1)
"endif
"else
"exec "let indent=".a:child
"return indent==-1?indent(v:lnum-1):indent
"endif
"endfunction
"augroup IndentIgnoringBlanks
"au!
"au FileType * if match(&indentexpr,'IndentIgnoringBlanks') == -1 |
"\ let &indentexpr = "IndentIgnoringBlanks('".
"\ substitute(&indentexpr,"'","''","g")."')" |
"\ endif
"augroup END
" make p in Visual mode overwrite the selected text with the previously yanked text
"vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
"This makes Vim break text to avoid lines getting longer than 78 characters.
"But only for files that have been detected to be plain text
"autocmd FileType text setlocal textwidth=78
" doesn't work right !!
"if exists("loaded_vimspell")
"set spell_auto_type="tex,mail,text,txt,html,sgml,otl"
":SpellAutoEnable
"endif
" Quick find file (I use FuzzyFinder now)
" Use ,f followed by the name: ,f readme <enter>
" Be careful not to use this in a directory with tons of sub-directories, as it can be slow in that situation
"function! Find(name)
"let l:_name = substitute(a:name, "\\s", "*", "g")
"let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" -and -not -name \"*.svn*\" | perl -ne 'print \"$.\\t$_\"'")
"let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
"if l:num < 1
"echo "'".a:name."' not found"
"return
"endif
"if l:num != 1
"echo l:list
"let l:input=input("Which ? (<enter>=nothing)\n")
"if strlen(l:input)==0
"return
"endif
"if strlen(substitute(l:input, "[0-9]", "", "g"))>0
"echo "Not a number"
"return
"endif
"if l:input<1 || l:input>l:num
"echo "Out of range"
"return
"endif
"let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
"else
"let l:line=l:list
"endif
"let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
"execute ":e ".l:line
"endfunction
"command! -nargs=1 Find :call Find("<args>")
"map ,f :Fi