-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
320 lines (243 loc) · 10.4 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
" VIM Configuration
" Original comes from Vincent Jousse
fun SetupVAM()
let c = get(g:, 'vim_addon_manager', {})
let g:vim_addon_manager = c
let c.plugin_root_dir = expand('$HOME', 1) . '/.vim/vim-addons'
let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'
" let g:vim_addon_manager = { your config here see "commented version" example and help
if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
execute '!git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '
\ shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
endif
call vam#ActivateAddons(['ack', 'ctrlp', 'EasyMotion', 'vim-snippets', 'Syntastic', 'The_NERD_tree'], {'auto_install' : 0})
" Also See "plugins-per-line" below
endfun
call SetupVAM()
" put this line first in ~/.vimrc
set nocompatible | filetype indent plugin on | syn on
" Set title on X window
set title
" Global
set hidden ruler wmnu " Hide buffer instead of abandoning when unloading
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pyc,*.pyo " Ignore certain files
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
syntax on
" Color scheme
let &t_Co=256 " force the 256-color mode
colorscheme mustang
set cursorline
hi cursorline cterm=none term=none " Highlight current line, disable underlining
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set ignorecase " Search in insensitive case
set smartcase " Search like ack with maj on ly if a maj
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
" set visualbell " No beeping.
set shortmess+=filmnrxoOtT " abbrev. of messages (avoids 'hit enter')
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set noswapfile " Use an SCM instead of swap files
set laststatus=2 " Show the status line all the time
set backspace=indent,eol,start " http://vim.wikia.com/wiki/Backspace_and_delete_problems
set expandtab
set copyindent " copy the previous indentation on autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set autoindent
set undolevels=1000 " use many levels of undo
if version >= 730
set noundofile " Don't keep a persistent undofile
endif
" http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste
" F2 = toggle paste mode
nnoremap <F2> :set invpaste paste?<Enter>
imap <F2> <C-O><F2>
set pastetoggle=<F2>
inoremap <F3> *
vnoremap <F3> y/<C-R>"<CR>
nmap <silent> <F3> n
nmap <silent> <S-F3> N
imap <silent> <F3> <C-O>n
imap <silent> <S-F3> <C-O>N
" Make the view port scroll faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Resize splitted views faster
nnoremap <C-w>< 5<C-w><
nnoremap <C-w>> 5<C-w>>
" Remap the marker char
nnoremap ' `
nnoremap ` '
" Line number toggle with F12
noremap <silent> <F12> :set number!<CR>
" Command and search pattern history
set history=1000
" Redifinition of map leader
let mapleader = ","
" make plugins smoother
set lazyredraw
" Always replace all occurences of a line
set gdefault
" Tabs and indentation. Yes, I like 4-space tabs (Symfony2 here we go !)
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Remove any trailing dos line break ^M
set ff=unix
nmap <leader>2 :set tabstop=2<cr>:set shiftwidth=2<cr>:set softtabstop=2<cr>
nmap <leader>4 :set tabstop=4<cr>:set shiftwidth=4<cr>:set softtabstop=4<cr>
" Sudo to write
command W w !sudo tee % > /dev/null
" Pull word under cursor into LHS of a substitute (for quick search and replace)
nmap <leader>zs :%s/<C-r>=expand("<cword>")<CR>/
" Pull word under cursor into Ack for a global search
map <leader>za :Ack "<C-r>=expand("<cword>")<CR>"
" Start a substitute
map <leader>s :%s/
" Ack
nmap <leader>a :Ack<space>
" Clear search highlight
map <silent> <leader>/ :let @/=""<CR>:echo "Cleared search register."<cr>
filetype on
filetype plugin on
filetype indent on
" Ctags
" set nocp
" set tags=tags
" map <silent><leader><Left> <C-T>
" map <silent><leader><Right> <C-]>
" map <silent><leader><Up> <C-W>]
"OmniCppComplete
" let OmniCpp_NamespaceSearch = 1
" let OmniCpp_GlobalScopeSearch = 1
" let OmniCpp_ShowAccess = 1
" let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
" let OmniCpp_MayCompleteDot = 1 " autocomplete after .
" let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
" let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
" let OmniCpp_DefaultNamespaces = ["std", _GLIBCXX_STD"]
" Completion
set complete=.,w,b,u,t,i,k~/.vim/syntax/php.api
au FileType php set omnifunc=phpcomplete#CompletePHP
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
" Allow extended digraphs
set encoding=utf-8
" Disable folding
set nofoldenable
" My information
iab xdate <C-R>=strftime("%d/%m/%Y %H:%M:%S")
" Markdown
au! BufRead,BufNewFile *.markdown,*.md set filetype=mkd
au! BufRead,BufNewFile *.md set filetype=mkd
" reStructuredText
au! BufRead,BufNewFile *.rst set filetype=rst
" Twig
au BufNewFile,BufRead *.twig set filetype=twig
" Twig surrounding
let g:surround_{char2nr('-')} = "{% \r %}"
" PHP/HTML
let php_htmlInStrings = 1
let php_sql_query = 1
" run file with PHP CLI (CTRL-M)
autocmd FileType php noremap <C-M> :w!<CR>:!/usr/bin/php %<CR>
" PHP parser check (CTRL-L)
autocmd FileType php noremap <C-L> :!/usr/bin/php -l %<CR>
"Invisible character
nmap <leader>l :set list!<CR>
set listchars=nbsp:¤,tab:>-,trail:¤,extends:>,precedes:<,eol:¬,trail:·
" Highlight trailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Does not work under version 7.1.6
if version >= 716
autocmd BufWinLeave * call clearmatches()
endif
" automatically remove trailing whitespace before write
function! StripTrailingWhitespace()
normal mZ
%s/\s\+$//e
if line("'Z") != line(".")
echo "Stripped whitespace\n"
endif
normal `Z
endfunction
autocmd BufWritePre *.php,*.yml,*.xml,*.js,*.html,*.css,*.java,*.c,*.cpp,*.vim :call StripTrailingWhitespace()
set statusline+=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
" Syntastic
"let g:syntastic_enable_signs = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_quiet_warnings=0
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
" Tab mappings.
map <leader>te :tabedit<space>
map <leader>tc :tabclose<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove<cr>
map <leader>tr :tabrewind<cr>
let g:CommandTMaxHeight=15
"fun SetupVAM()
" " YES, you can customize this vam_install_path path and everything still works!
" let vam_install_path = expand('$HOME') . '/.vim/vim-addons'
" exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager'
" " * unix based os users may want to use this code checking out VAM
" " * windows users want to use http://mawercer.de/~marc/vam/index.php
" " to fetch VAM, VAM-known-repositories and the listed plugins
" " without having to install curl, unzip, git tool chain first
" if !isdirectory(vam_install_path.'/vim-addon-manager') && 1 == confirm("git clone VAM into ".vam_install_path."?","&Y\n&N")
" I'm sorry having to add this reminder. Eventually it'll pay off.
" call confirm("Remind yourself that most plugins ship with documentation (README*, doc/*.txt). Its your first source of knowledge. If you can't find the info you're looking for in reasonable time ask maintainers to improve documentation")
" exec '!p='.shellescape(vam_install_path).'; mkdir -p "$p" && cd "$p" && git clone --depth 1 git://github.com/MarcWeber/vim-addon-manager.git'
" endif
" call vam#ActivateAddons(['ack', 'ctrlp', 'EasyMotion', 'vim-snippets', 'Syntastic', 'The_NERD_tree'], {'auto_install' : 1})
" sample: call vam#ActivateAddons(['pluginA','pluginB', ...], {'auto_install' : 0})
" where pluginA could be github:YourName or snipmate-snippets see vam#install#RewriteName()
" also see section "5. Installing plugins" in VAM's documentation
" which will tell you how to find the plugin names of a plugin
"endf
"call SetupVAM()
" experimental: run after gui has been started (gvim) [3]
" option1: au VimEnter * call SetupVAM()
" option2: au GUIEnter * call SetupVAM()
" See BUGS sections below [*]
"let vam_install_path = expand('$HOME') . '/.vim/vim-addons'
"exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager'
"call vam#ActivateAddons(['ack', 'ctrlp', 'EasyMotion', 'vim-snippets', 'Syntastic', 'The_NERD_tree'], {'auto_install' : 0})
function! OpenPhpFunction (keyword)
let proc_keyword = substitute(a:keyword , '_', '-', 'g')
exe 'split'
exe 'enew'
exe "set buftype=nofile"
exe 'silent r!lynx -dump -nolist http://www.php.net/manual/en/print/function.'.proc_keyword.'.php'
exe 'norm gg'
exe 'call search ("' . a:keyword .'")'
exe 'norm dgg'
" exe 'call search("User Contributed Notes")'
" exe 'norm dGgg'
endfunction
au FileType php map K :call OpenPhpFunction('<C-r><C-w>')<CR>
let g:ackprg="ack -H --nocolor --nogroup --column --smart-case"
" Go to last file(s) if invoked without arguments.
autocmd VimLeave * nested if (!isdirectory($HOME . "/.vim")) |
\ call mkdir($HOME . "/.vim") |
\ endif |
\ execute "mksession! " . $HOME . "/.vim/Session.vim"
autocmd VimEnter * nested if argc() == 0 && filereadable($HOME . "/.vim/Session.vim") |
\ execute "source " . $HOME . "/.vim/Session.vim"
" ctrlp shortcut
let g:ctrlp_map = '<c-p>'