forked from nviennot/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
257 lines (208 loc) · 7.35 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
"""""""""""""""""""""""""
" Basic features
"""""""""""""""""""""""""
let pathogen_disabled = []
if !has('gui_running')
call add(g:pathogen_disabled, 'css-color')
endif
call pathogen#infect()
" Display options
syntax on
set cursorline
set number
set list! " Display unprintable characters
set listchars=tab:▸\ ,trail:•,extends:»,precedes:«
if $TERM =~ '256color'
set t_Co=256
elseif $TERM =~ '^xterm$'
set t_Co=256
endif
colorscheme molokai
" Misc
filetype plugin indent on " Do filetype detection and load custom file plugins and indent files
set hidden " Don't abandon buffers moved to the background
set wildmenu " Enhanced completion hints in command line
set wildmode=list:longest,full " Complete longest common match and show possible matches and wildmenu
set backspace=eol,start,indent " Allow backspacing over indent, eol, & start
set complete=.,w,b,u,U,t,i,d " Do lots of scanning on tab completion
set updatecount=100 " Write swap file to disk every 100 chars
set directory=~/.vim/swap " Directory to use for the swap file
set diffopt=filler,iwhite " In diff mode, ignore whitespace changes and align unchanged lines
set history=1000 " Remember 1000 commands
set scrolloff=3 " Start scrolling 3 lines before the horizontal window border
set visualbell t_vb= " Disable error bells
set shortmess+=A " Always edit file, even when swap file is found
" up/down on displayed lines, not real lines. More useful than painful.
noremap k gk
noremap j gj
" Formatting, indentation and tabbing
set autoindent smartindent
set smarttab " Make <tab> and <backspace> smarter
set expandtab
set tabstop=2
set shiftwidth=2
set textwidth=80
set formatoptions-=t formatoptions+=croql
" viminfo: remember certain things when we exit
" (http://vimdoc.sourceforge.net/htmldoc/usr_21.html)
" % : saves and restores the buffer list
" '100 : marks will be remembered for up to 30 previously edited files
" /100 : save 100 lines from search history
" h : disable hlsearch on start
" "500 : save up to 500 lines for each register
" :1000 : up to 1000 lines of command-line history will be remembered
" n... : where to save the viminfo files
set viminfo=%100,'100,/100,h,\"500,:1000,n~/.vim/viminfo
" ctags: recurse up to home to find tags. See
" http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks
" for an explanation and other ctags tips/tricks
set tags+=tags;$HOME
" Undo
set undolevels=10000
if has("persistent_undo")
set undodir=~/.vim/undo " Allow undoes to persist even after a file is closed
set undofile
endif
" Search settings
set ignorecase
set smartcase
set hlsearch
set incsearch
set showmatch
" to_html settings
let html_number_lines = 1
let html_ignore_folding = 1
let html_use_css = 1
let xml_use_xhtml = 1
" When opening a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"zz" |
\ endif |
" After 4s of inactivity, check for external file modifications on next keyrpress
au CursorHold * checktime
"""""""""""""""""""""""""
" Keybindings
"""""""""""""""""""""""""
let mapleader=","
let localmapleader=","
nmap <Leader>s :%S/
vmap <Leader>s :S/
vnoremap . :normal .<CR>
vnoremap @ :normal! @
" Toggles
set pastetoggle=<F1>
" the nmap is just for quicker powerline feedback
nmap <silent> <F1> :set invpaste<CR>
nmap <F2> :setlocal spell!<CR>
imap <F2> <C-o>:setlocal spell!<CR>
nmap <silent> <F3> :set invwrap<CR>
" TODO toggle numbers
map <Leader>/ :nohlsearch<cr>
map <Home> :tprev<CR>
map <End> :tnext<CR>
" TODO Do also cnext and cprev as a fallback
map <PageDown> :lnext<CR>
map <PageUp> :lprev<CR>
" Make Y consistent with D and C
function! YRRunAfterMaps()
nnoremap <silent> Y :<C-U>YRYankCount 'y$'<CR>
endfunction
" Disable K for manpages - not used often and easy to accidentally hit
noremap K k
" Resize window splits
" TODO Fix mousewheel
nnoremap <Up> 3<C-w>-
nnoremap <Down> 3<C-w>+
nnoremap <Left> 3<C-w><
nnoremap <Right> 3<C-w>>
nnoremap _ :split<cr>
nnoremap \| :vsplit<cr>
vmap s :!sort<CR>
vmap u :!sort -u<CR>
" Write file when you forget to use sudo
cmap w!! w !sudo tee % >/dev/null
"""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""
nnoremap <Leader>b :BufSurfBack<cr>
nnoremap <Leader>f :BufSurfForward<cr>
nnoremap <S-u> :GundoToggle<CR>
let g:gundo_close_on_revert=1
" TODO Merge the NERDTreeFind with Toggle inteilligently.
nnoremap <C-g> :NERDTreeToggle<cr>
let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.py\$class$', '\.obj$', '\.o$',
\ '\.so$', '\.egg$', '^\.git$', '\.cmi', '\.cmo' ]
let NERDTreeHighlightCursorline=1
let NERDTreeShowBookmarks=1
let NERDTreeShowFiles=1
nnoremap <silent> <Leader>gd :Gdiff<CR>
nnoremap <silent> <Leader>gb :Gblame<CR>
nnoremap <Leader>a :Ack
" Put a space around comment markers
let g:NERDSpaceDelims = 1
nnoremap <C-y> :YRShow<cr>
let g:yankring_history_dir = '$HOME/.vim'
let g:yankring_manual_clipboard_check = 0
map <Leader>l :MiniBufExplorer<cr>
let g:miniBufExplorerMoreThanOne = 10000
let g:miniBufExplModSelTarget = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplSplitBelow=1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplVSplit = 20
let g:syntastic_enable_signs=1
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['c', 'scss', 'html', 'scala'] }
let g:quickfixsigns_classes=['qfl', 'vcsdiff', 'breakpoints']
let g:Powerline_symbols = 'unicode'
set laststatus=2
let g:ctrlp_map = '<Leader>.'
let g:ctrlp_custom_ignore = '/\.\|\.o\|\.so'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_regexp = 1
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
noremap \= :Tabularize /=<CR>
noremap \: :Tabularize /^[^:]*:\zs/l0l1<CR>
noremap \> :Tabularize /=><CR>
noremap \, :Tabularize /,\zs/l0l1<CR>
noremap \{ :Tabularize /{<CR>
noremap \\| :Tabularize /\|<CR>
noremap \& :Tabularize /\(&\\|\\\\\)<CR>
nnoremap <Leader>t :TagbarOpen fjc<CR>
" Screen settings
let g:ScreenImpl = 'Tmux'
let g:ScreenShellTmuxInitArgs = '-2'
let g:ScreenShellInitialFocus = 'shell'
let g:ScreenShellQuitOnVimExit = 0
map <C-\> :ScreenShellVertical<CR>
"""""""""""""""""""""""""
" Ruby Stuff
"""""""""""""""""""""""""
command -nargs=? -complete=shellcmd W :w | :call ScreenShellSend("load '".@%."';")
map <Leader>r :w<CR> :call ScreenShellSend("rspec ".@% . ':' . line('.'))<CR>
map <Leader>e :w<CR> :call ScreenShellSend("cucumber --format=pretty ".@% . ':' . line('.'))<CR>
map <Leader>w :w<CR> :call ScreenShellSend("break ".@% . ':' . line('.'))<CR>
map <Leader>, :w<CR> :call ScreenShellSend("\e[A")<CR>
"""""""""""""""""""""""""
" Cscope
"""""""""""""""""""""""""
if has("cscope")
" Use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" Check cscope for definition of a symbol before checking ctags. Set to 1 if
" you want the reverse search order.
set csto=0
" Add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
endif
" Show msg when any other cscope db is added
set cscopeverbose
end
"""""""""""""""""""""""""
" Local config
"""""""""""""""""""""""""
so ~/.vim/vimrc.mine
" TODO raise contrast for comments