-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
400 lines (339 loc) · 9.87 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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
" Vim, not vi
set nocompatible
" Sets the language of the menu (gvim)
set langmenu=en_US.UTF-8
" Sets the language of the messages / ui (Vim)
language messages en
" Remove ALL autocommands for the current group
autocmd!
" Automatically use system clipboard
set clipboard=unnamed
" Disable cursor blinking
set guicursor+=a:blinkon0
" Enable mouse support in console
set mouse=a
" Change Leader key
let mapleader = ","
" Activate Vundle
set runtimepath+=~/.vim/bundle/vundle/
call vundle#rc()
" Plugins {{{
" The mother of all bundles
Bundle "gmarik/vundle"
Bundle "FuzzyFinder"
" FuzzyFinder mapping - open buffers
nnoremap <Leader>ls :FufBuffer<CR>
" fuf mapping - all files in current directory
nnoremap <Leader>lf :FufCoverageFile<CR>
" fuf mapping - most recently used files
nnoremap <Leader>lr :FufMruFile<CR>
" fuf mapping - open bookmarked files
nnoremap <Leader>lb :FufBookmarkFile<CR>
" fuf mapping - add file to bookmarks
nnoremap <Leader>la :FufBookmarkFileAdd<CR>
" Enable fuf mru mode
let g:fuf_modesDisable = [ 'mrucmd', ]
" Graphical undo
Bundle "sjl/gundo.vim"
nnoremap <F5> :GundoToggle<CR>
Bundle "ervandew/supertab"
" Enable longest common match
let g:SuperTabLongestEnhanced = 1
" Enable context autocomplete
let g:SuperTabDefaultCompletionType = "context"
Bundle "majutsushi/tagbar"
" Map tagbar outline toggle
nnoremap <F8> :TagbarToggle<CR>
" Tagbar configuration
let g:tagbar_usearrows = 1
let g:tagbar_sort = 0
" OpenBrowser - open links under cursor
Bundle "tyru/open-browser.vim"
let g:netrw_nogx = 1 " disable netrw's gx mapping
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
Bundle "kien/ctrlp.vim"
let g:ctrlp_map = '<C-P>'
let g:ctrlp_cmd = 'CtrlPMixed'
Bundle "Lokaltog/vim-powerline"
" Use short path name
let g:Powerline_stl_path_style = 'short'
call Pl#Theme#RemoveSegment('fugitive:branch')
" Kill buffer preserving window:
" ,(!)bd - kill buffer
Bundle "bufkill.vim"
" Some quick switching
nnoremap <C-Tab> :BB<CR>
nnoremap <C-S-Tab> :BF<CR>
" Expore hex view of file with ,hm
"Bundle 'hexman.vim'
Bundle "scrooloose/syntastic"
"
" Comment out lines with ,cs
" Toggle comments with ,ci
Bundle "scrooloose/nerdcommenter"
" Explore filesystem with :NERDTreeToggle
Bundle "scrooloose/nerdtree"
Bundle "tpope/vim-fugitive"
Bundle "tpope/vim-surround"
Bundle "tpope/vim-unimpaired"
Bundle "Kris2k/matchit"
Bundle "Rip-Rip/clang_complete"
Bundle "bronson/vim-visual-star-search"
" Manipulate gists:
" create - :Gist
Bundle "mattn/gist-vim"
Bundle "mileszs/ack.vim"
Bundle "Townk/vim-autoclose"
" Filetype-specific plugins
Bundle "PProvost/vim-ps1"
Bundle "othree/html5.vim"
Bundle "derekwyatt/vim-scala"
Bundle "klen/python-mode"
Bundle "xml.vim"
" Color schemes
Bundle "altercation/vim-colors-solarized"
" Support bundles
Bundle "mattn/webapi-vim"
Bundle "L9"
"}}}
" Change default directory
cd ~\Scripts\
" Manual folding (zf)
set foldmethod=marker
" Set correct Unicode processing
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8 "better default than latin1
setglobal fileencoding=utf-8 "change default file encoding when writing new files
set fileencodings=utf8,uft-16le,cp1251
endif
" Set switching language on <C-^>
set keymap=ukrainian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=NONE guibg=Green
" Use more prompt
set more
" Watch for file changes
set autoread
" Hide buffers when they are abandoned
set hidden
" Show current mode
set showmode
" Show (partial) command in status line
set showcmd
" Keep at least several lines above/below
set scrolloff=2
" Keep at least several lines left/right
set sidescrolloff=5
" Make sure backspace is unstoppable
set backspace=indent,eol,start
" 1000 undos
set undolevels=1000
" Remember history
set history=200
" Enable syntax highlighting
syntax on
" Enable filetype detection
filetype on
" Enable filetype-specific indenting
filetype indent on
" Enable filetype-specific plugins
filetype plugin on
" {{{ GUI CLEANUP
" Makes gui the way I like it
if has("gui_running")
"colorscheme zenburn
set background=dark
colorscheme solarized
"Muck with gvim interface
"remove toolbar
set guioptions-=T
"Remove right scrollbar
set guioptions-=r
set guioptions-=R
"remove left scrollbar
set guioptions-=l
set guioptions-=L
"remove menu bar
set guioptions-=m
"Consolas is AWESOME
set guifont=Consolas:h10
endif
" Maximize window on start
autocmd GUIEnter * simalt ~x
" }}}
"{{{ AUTO-COMPLETION
" Enable omni-completion
set omnifunc=syntaxcomplete#Complete
" Complete longest common string, list alternatives
set wildmode=longest,list
" Menu has tab completion
set wildmenu
" Don't select first item, follow typing in autocomplete
set completeopt=menuone,longest,preview
set pumheight=6 " Keep a small completion window
" Don't care about binary/temporary files
set wildignore=*.swp,*.pyo,*.pyc,*.class
set wildignore+=*.o,*.obj,.git
" }}}
"{{{ SEARCHING
" Incremental search
set incsearch
" Search ignoring case
set ignorecase
" Highlight the search
set hlsearch
" Show matching bracket
set showmatch
" Sane regexes
" nnoremap / /\v
" vnoremap / /\v
" Match capital and not-capital letters alike
set smartcase
" Set substitute search to replace all ocurrences by default
set gdefault
" Ignore all whitespace and sync
set diffopt=filler,iwhite
" }}}
"{{{ BACKUP
" Set fixed backup/swap/undo directory
" set backupdir=$VIM/backup
set nobackup
set nowritebackup
" set directory=$VIM/swap
set noswapfile
set undodir=$VIM/undo
set undofile
" }}}
"{{{ COMMON MISSPELLINGS
abbr teh the
" }}}
"{{{ INDENTATION
" Spaces are inserted instead of tabs
set expandtab
" Tab in front of a line inserts 'shiftwidth' blanks
set smarttab
" Number of spaces for indent
set shiftwidth=4
" For how many spaces Tabs in file count
set tabstop=4
" Copy indent from current line when starting a new line
set autoindent
" Indent is automatically inserted in functions' {/}
set smartindent
" Add jspf syntax
autocmd BufNewFile,BufRead *.jspf set filetype=jsp
" Also .tag files
autocmd BufNewFile,BufRead *.tag set filetype=jsp
" Spell-checker - ftp://ftp.vim.org/pub/vim/runtime/spell/
set spelllang=en,ru_ru,uk
" Split words on punctuation with word-wrap
set linebreak
" Highlight line under cursor
set cursorline
" }}}
"{{{ QUICK EDITS
" Edit vimrc in current buffer
nnoremap <Leader>v :edit $VIM/.vimrc<CR>
" Edit hosts file (should run under Admin)
nnoremap <Leader>h :edit C:/Windows/System32/drivers/etc/hosts<CR>
" Edit my personal notes file
nnoremap <Leader>n :edit $Dropbox/Notes.txt<CR>
" Change path to current directory
nnoremap <Leader>cd :cd %:p:h<CR>:pwd<CR>
" Get current filename (head) in clipboard
nnoremap <Leader>ff :let @*=expand("%:t")<CR>
" Get full path in clipboard
nnoremap <Leader>fp :let @*=expand("%:p")<CR>
" Get directory of file (tail) in clipboard
nnoremap <Leader>fd :let @*=expand("%:h")<CR>
" Reload vimrc file
nnoremap <Leader>m :source $VIM/.vimrc<CR>
" }}}
"{{{ MAPPINGS
" Toggle line numbers
nnoremap <F11> :set invnumber<CR>
" Toggle line-wrap
nnoremap <F12> :set wrap!<CR>
" Toggle spelling
nnoremap <F7> :set spell!<CR>
inoremap <F7> <C-o>:set spell!<CR>
" Toggle list mode - shows hidden characters
nnoremap <F9> :set list!<CR>
" Space will toggle folds!
" nnoremap <Space> za
" Set mapping for highlighting toggle
nnoremap <Leader><Space> :nohlsearch<CR>
" Substitute all occurrences of the word under the cursor
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" Trim whitespace
nnoremap <Leader>W :%s/\s\+$//<CR>
" Change encoding to utf-16le (for log files)
nnoremap <Leader>log :e ++enc=utf-16le<CR>
" Search pharase under selection
" vnoremap * y/<C-R>*<CR>N
" Count expression under search
nnoremap <Leader>z :%s///n<CR>
" Up and down are more logical with g - wrapped lines count
nnoremap k gk
nnoremap j gj
" Create Blank Newlines and stay in Normal mode
nnoremap zj o<Esc>
nnoremap zk O<Esc>
" Center on next match
nnoremap N Nzz
nnoremap n nzz
" Easy window navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" Easy window movement
noremap <Leader>wj <C-w><S-j>
noremap <Leader>wh <C-w><S-h>
noremap <Leader>wk <C-w><S-k>
noremap <Leader>wl <C-w><S-l>
" Make * just highlight current word
nnoremap * *N
" Swap ; and : in Normal mode
" nnoremap ; :
" nnoremap : ;
" Make delete inner word also delete space after it
nmap diw hebdw
" Disable some mappings
" F1 for help; :help is more useful
nnoremap <F1> <nop>
" Q to start ex mode; intended to start recording a macro with q
nnoremap Q <nop>
" Disable K to bring up a man page for the word under the cursor
nnoremap K <nop>
" Consistent yanking
nnoremap Y y$
" Mapping to copy contents of the buffer to clipboard
nnoremap <Leader>ya :%y*<CR>
" Mapping to replace contents of the buffer with clipboard's
nnoremap <Leader>yp ggVG"_dP<CR>
" }}}
"{{{ PLUGIN CONFIGURATION
" Javascript indent configuration for html.vim
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" }}}
"{{{ MISC
" Set off the other paren
highlight MatchParen ctermbg=4
" Always have status line in last window
set laststatus=2
set statusline=%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%]
set virtualedit=block " Let cursor move past the last char in <C-v> mode
set fileformats=unix,dos,mac " Try recognizing dos, unix, and mac line endings
" Authomatic foling for xml files
let g:xml_syntax_folding=1
au FileType xml setlocal foldmethod=syntax
au FileType jsp setlocal foldmethod=syntax
" }}}