-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.vimrc
337 lines (266 loc) · 9.57 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
" Modified: Wed 08 Nov 2017 11:57:27 PM CET
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set encoding=utf-8
set fileformat=unix
set fileformats=unix,dos,mac
try
lang en_US
catch
endtry
" initialize an empty array for disabled pathogen plugins
let g:pathogen_disabled = []
" call add(g:pathogen_disabled, 'sparkup')
call pathogen#infect()
set ai " always set autoindenting on
" File-type
filetype on
filetype plugin on
filetype indent on
syntax on
"set backspace=2 " allow backspacing over everything in insert mode
" allow <BkSpc> to delete line breaks, beyond the start of the current
" insertion, and over indentations:
set backspace=eol,start,indent
silent execute '!mkdir -p ~/.vim/backup'
set backupdir=~/.vim/backup/
set backupskip=/tmp/*,/private/tmp/*
"helptags ~/.vim/doc
set ml " enable modelines
set list " show whitespace
set backup " keep a backup file
set cindent
set complete=k,.,w,b,u,t,i
set directory=~/.vim/backup,/tmp " This is where the swapfiles go
set history=1000 " keep 50 lines of command line history
set undolevels=1000
set incsearch " Incremental search on - Show match as search is typed
"set ignorecase " Ignore the case when searching
set smartcase " Override the 'ignorecase' option if the search pattern contains ucase
set laststatus=2 " Show status only when there are more than two windows
set lazyredraw " Don't redraw while executing macros (good performance config)
set cmdheight=2 " Helps avoiding 'hit enter' prompt
set listchars=tab:>.,trail:-,extends:#,nbsp:.
set foldmethod=indent
set foldminlines=5
set foldlevelstart=99 " 99 effectively disables auto-folds. see :help foldlevelstart
set magic " Use some magic in search patterns
set matchtime=2 " Show the match for n tenths of a second
set noerrorbells " Damn error bells!
set noexpandtab
set copyindent
set nostartofline " Don't jump to start of line on pagedown
set nrformats+=alpha " Allows CTRL-A and CTRL-X to increment/decrement letters
set pastetoggle=<F5>
set ruler " show the cursor position all the time
"if exists('+colorcolumn')
" set colorcolumn=+1
"endif
set scrolloff=3 " Keep 3 lines above and below the cursor
set shell=/bin/bash " Shell to use for ! and :! commands
set shiftwidth=2
set shortmess=aI " Avoid 'Hit enter to continue' message, no intro msg
set showbreak=+ " Show character at beginning of wrapped line
set showcmd " Show uncompleted command
set showmatch " Show the matching closing bracket
set showmode " Show current edit mode
set smartindent " Indent after { has been typed
set softtabstop=2
set splitbelow " Create new window below current one
set tabstop=2
set title
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%)
set ttyfast " We're running on a fast terminal
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :50 : up to 50 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:50,%,n~/.viminfo
set visualbell " Better than a beep
set nowrap " Don't wrap long lines
set whichwrap=<,>,h,l,~,[,] " Left/right motion line wrap
" 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
set wildchar=<TAB> " the char used for "expansion" on the command line
set wildmenu
set wildignore+=*.DS_Store,*.o,*.obj,.git,.svn,*.pyc " Ignore certain files in wildmenu
" normally don't automatically format `text' as it is typed, IE only do this
" with comments, at 79 characters:
set formatoptions-=t
set textwidth=79
set mouse=a
" powerline statusbar
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
" golint linting
set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
" Set up pretty colors
set background=dark
let myColorscheme = 'default'
set number "show line numbers
if &term ==? 'xterm-256color' || &term ==? 'screen-256color-bce' || &term ==? 'screen-256color'
set t_Co=256
execute "colorscheme ".myColorscheme
else
colorscheme default
endif
" 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 editing of the .vimrc
map <leader>e :tabedit! ~/.vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
" Fast editing of the colorscheme
silent execute "map <leader>co :tabedit! ~/.vim/colors/".myColorscheme.".vim<cr>"
" When colorscheme is edited, reload it
autocmd! bufwritepost ~/.vim/colors/*.vim execute "colorscheme ".myColorscheme
" Make ;w work http://nvie.com/posts/how-i-boosted-my-vim/
nnoremap ; :
" Saving shortcuts
nmap <F2> :w<C-M>
nmap <F4> :wq<C-M>
nmap <F10> :qall<C-M>
map <F1> <Esc>
" Open/Close folds with space
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Use system-wide clipboard
set clipboard+=unnamed
" Copy to clipboard
map <leader>c "+y<cr>
" Let's see some useful info in the status line
" set statusline=%f\ %1*%m%*%=[%{strlen(&fenc)?&fenc:'none'},%{&ff}]\ %{fugitive#statusline()}\ %2*%r%*%w\ %l,%c-%v/%L\ %P
" Session management
" Maybe checkout http://peterodding.com/code/vim/session/
silent execute '!mkdir -p ~/.vim/sessions'
nmap SM :wa<C-M>:mksession! ~/.vim/sessions/
nmap SO :wa<C-M>:source ~/.vim/sessions/
" View management
au BufWritePost,BufLeave,WinLeave ?* mkview
au BufWritePost,BufLeave,WinLeave quickfix au!
au BufWinEnter ?* silent loadview
au BufWinEnter quickfix au!
" Delete trailing whitespace
nmap <leader>wd :%s/\s\+$//<cr>
vmap <leader>wd :s/\s\+$//<cr>
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Use Q for formatting the current paragraph (or selection)
vmap Q gq
nmap Q gqap
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <Left> :tabprevious<CR>
map <Right> :tabnext<CR>
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
" http://cloudhead.io/2010/04/24/staying-the-hell-out-of-insert-mode/
inoremap kj <Esc>
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
set hlsearch
map <C-\> :nohlsearch<CR>
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" When editing a file, always jump to the last cursor position.
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
endif " has("autocmd")
" 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>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
" command-T
let g:CommandTMaxHeight = 30
noremap <leader>ct :CommandT<cr>
noremap <leader>cty :CommandTFlush<cr>
"map <D-t> :CommandT<CR>
" Cope
" Do :help cope if you are unsure what cope is. It's super useful!
map <leader>ccc :botright cope 20<cr>
map <leader>\ :ccl<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>
" Tagbar http://majutsushi.github.com/tagbar/
let g:tagbar_autofocus = 1
let g:tagbar_usearrows = 1
au BufWinEnter *.js TagbarOpen
au BufWinEnter *.php TagbarOpen
map <leader>tb :TagbarToggle<cr>
" restore debug.vim from ~/.vim/plugins/attic
"let g:debuggerMaxChildren = 64
"let g:debuggerMaxData = 2048
"let g:debuggerMaxDepth = 10
" Start NERDTree
" autocmd VimEnter * NERDTree
" Move cursor to main window
autocmd VimEnter * wincmd p
" Close vim if NERDTree is the last open buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
map <leader>nt :NERDTreeToggle<cr>
" Sparkup
let g:sparkupNextMapping = '<c-n>'
let g:sparkupExecuteMapping = '<c-e>'
" Set some sane defaults before customizing SuperTab etc.
set omnifunc=syntaxcomplete#Complete
set completefunc=syntaxcomplete#Complete
" PHP Code completion
" autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" Add PHP Omni Completion to SuperTab
" let g:SuperTabDefaultCompletionType = "<c-x><c-o>"
let g:SuperTabDefaultCompletionType = "context"
" http://amix.dk/vim/vimrc.html
autocmd FileType *
\ if &omnifunc != '' |
\ call SuperTabChain(&omnifunc, "<c-p>") |
\ call SuperTabSetDefaultCompletionType("<c-x><c-u>") |
\ endif
" fix common typos
:command WQ wq
:command Wq wq
:command W w
:command Q q