-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.vimrc
More file actions
351 lines (278 loc) · 9.06 KB
/
.vimrc
File metadata and controls
351 lines (278 loc) · 9.06 KB
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
" .vimrc by Niko Riitala <nri@iki.fi>. Twitter: @nikoriitala
" No copyright, feel free to use this, as you like.
"
" General VIM settings file. Optimized for Drupal / PHP coding.
" Most of this file is copied from Tobias Schlitt's version of .vimrc
"cabbr checkjs !js /home/niko/bin/runjslint.js "`cat %`" \| lynx --force-html /dev/fd/5 -dump 5<&0 \| less
" {{{ File handling
au BufRead,BufNewFile *.phps set filetype=php
au BufRead,BufNewFile *.phtml set filetype=php
au BufRead,BufNewFile *.module set filetype=php
au BufRead,BufNewFile *.inc set filetype=php
au BufRead,BufNewFile *.install set filetype=php
au BufRead,BufNewFile *.test set filetype=php
au BufRead,BufNewFile *.profile set filetype=php
au BufRead,BufNewFile *.theme set filetype=php
au BufRead,BufNewFile *.sass set filetype=sass
"au BufRead,BufNewFile *.css set filetype=php
au BufRead,BufNewFile *.pl set filetype=perl6
au BufRead,BufNewFile *.txt setlocal ft=txt
au! BufRead,BufNewFile *.mkd setfiletype mkd
au BufRead,BufNewFile *.todo setfiletype todo
"check for Perl 6 code
function! LooksLikePerl6 ()
if getline(1) =~# '^#!.*/bin/.*perl6'
set filetype=perl6
else
for i in [1,2,3,4,5]
if getline(i) == 'use v6;'
set filetype=perl6
break
endif
endfor
endif
endfunction
au bufRead *.pm,*.t,*.pl call LooksLikePerl6()
" }}}
" {{{ Vim Settings
" for manually compiled Vim 7.3
"let &runtimepath.=',/home/niko/vim/runtime'
"let $VIMRUNTIME = "/home/niko/vim/runtime"
set undofile " Save undo's after file closes
set undodir=/home/niko/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
" old vim thingies continue
syntax on
" highlight current line in insert mode.
"autocmd InsertLeave * se nocul
"autocmd InsertEnter * se cul
" switch paste mode off whenever insert mode is left
" autocmd InsertLeave <buffer> se nopaste
" source .vimrc after saving .vimrc
"autocmd bufwritepost .vimrc source $MYVIMRC
" colored column (to see line size violations)
"set colorcolumn=80
" use filetype plugins, e.g. for PHP
filetype plugin on
" show nice info in ruler
set ruler
set laststatus=2
" set standard setting for pear coding standards
set tabstop=2
set shiftwidth=2
" auto expand tabs to spaces
set expandtab
" auto indent after a {
set autoindent
set smartindent
" reselect visual block after indent/outdent
"vnoremap < <gv
"vnoremap > >gv
" show line numbers by default
set number
" enable folding by fold markers
set foldmethod=marker
" autoclose folds, when moving out of them
set foldclose=all
" use incremental searching
set incsearch
" do not highlight search results
" set nohlsearch
"set scrolljump=5
set scrolloff=5
" repair wired terminal/vim settings
set backspace=start,eol,indent
" toggle paste
set pastetoggle=§
set wrap
" backup settings
"set backup
"set backupdir=/home/niko/.vim-backup
"fun! InitBex()
" let aika = strftime("%y%m%d-%H%M")
" let myvar = "set backupext=_". aika
" execute myvar
" echo myvar
"endfun
"au BufWritePre * call InitBex()
"set backupskip=/tmp/*,/private/tmp/*
" W for write
"cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
"cnoreabbrev <expr> Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq'))
"cnoreabbrev <expr> Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q'))
" fix mistype :W and :Q
command! -bang -range=% -complete=file -nargs=* WQ <line1>,<line2>wq<bang> <args>
command! -bang -complete=file -nargs=* Qa qa<bang>
command! -bang -complete=file -nargs=* QA qa<bang>
command! -bang -range=% -complete=file -nargs=* Wq <line1>,<line2>wq<bang> <args>
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>w<bang> <args>
command! -bang Q quit<bang>
" Powerline
" Remove delay between modes.
set timeoutlen=1000 ttimeoutlen=0
let g:powerline_config_path = $HOME.'/.config/powerline/config_files'
set noshowmode
" }}}
" {{{ Misc settings, mappings, term settings
" some mappings
map t :tabnew
nnoremap <C-f> :FufFile<CR>
nnoremap <C-d> :DiffChangesDiffToggle<CR>
nnoremap <C-s> :SyntasticCheck<CR>
" drush mappings
nnoremap <leader>dcca :!drush cc all<CR>
nnoremap <leader>dcm :!drush cc menu<CR>
nnoremap <leader>dct :!drush cc theme<CR>
nnoremap <leader>dcc :!drush cc css+js<CR>
nnoremap <leader>dul :!drush uli<CR>
" git mappings
nnoremap <Leader>gd :Gdiff<Enter>
nnoremap <Leader>gD :GitDiff --cached<Enter>
nnoremap <Leader>gs :Gstatus<Enter>
nnoremap <Leader>gl :GitLog<Enter>
nnoremap <Leader>ga :GitAdd<Enter>
nnoremap <Leader>gA :GitAdd <cfile><Enter>
nnoremap <Leader>gc :GitCommit<Enter>
nnoremap <Leader>gp :GitPullRebase<Enter>
" write with sudo ":w!!"
cnoremap w!! w !sudo tee % >/dev/null
nnoremap <silent> <F8> :TlistToggle<CR>
nnoremap <silent> <F9> :NERDTree<CR>
nnoremap <silent> <C-D> :DiffSaved<CR>
" Reselect visual block after indent/outdent
"vnoremap < <gv
"vnoremap > >gv
" Move lines up and down
"nnoremap <S-j> :m .+1<CR>==
"nnoremap <S-k> :m .-2<CR>==
"noremap <S-k> :m .-2<CR>==gi<ESC>
"noremap <S-j> :m .+1<CR>==gi<ESC>
" " " "vnoremap <S-j> :m '>+1<CR>gv=gv
" " " "vnoremap <S-k> :m '<-2<CR>gv=gv
nnoremap <S-Down> :m .+1<CR>==
nnoremap <S-Up> :m .-2<CR>==
inoremap <S-Down> <Esc>:m .+1<CR>==gi
inoremap <S-Up> <Esc>:m .-2<CR>==gi
vnoremap <S-Down> :m '>+1<CR>gv=gv
vnoremap <S-Up> :m '<-2<CR>gv=gv
map <C-l> :vertical wincmd f<CR>
"map <C-p> :CtrlP<CR>
map <C-t> :tabnew<CR>
map <S-Left> :tabp<CR>
map <S-Right> :tabn<CR>
nmap <silent> <C-Up> :wincmd k<CR>
nmap <silent> <C-Down> :wincmd j<CR>
nmap <silent> <C-Right> :wincmd l<CR>
nmap <silent> <C-Left> :wincmd h<CR>
hi Comment ctermfg=blue
" fix arrow keys
set t_ku=OA
set t_kd=OB
set t_kr=OC
set t_kl=OD
set background=dark
" run zsh inside vim
let g:ConqueTerm_TERM = 'xterm'
command Z :ConqueTermVSplit zsh
" Change current work directory
command CD :cd %:p:h
" Count non-blank lines on current file
command Lines :!cat %|sed '/^\s*$/d'|wc -l
" Map leader key for nercommenter
let mapleader = ","
" CtrlP settings
"set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
"let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" let g:ctrlp_working_path_mode = 'ra'
"let g:ctrlp_working_path_mode = 0
"let g:ctrlp_dotfiles = 0
"let g:ctrlp_switch_buffer = 0
"let g:ctrlp_match_window_reversed = 0
" Some Drupal coding standard stuff
let g:syntastic_phpcs_conf=" --standard=$HOME/.drush/coder/coder_sniffer/Drupal --extensions=php,module,inc,install,test,profile,theme"
let g:syntastic_php_checkers = ['php', 'phpcs']
let g:syntastic_php_phpcs_args=" --standard=$HOME/.drush/coder/coder_sniffer/Drupal --extensions=php,module,inc,install,test,profile,theme"
let g:syntastic_sass_checkers = ['sass']
" Other Syntastic settings
let g:syntastic_error_symbol = "✗"
let g:syntastic_warning_symbol = "⚠"
" Double slash -> Case insensitive search
map // /\c
map ?? ?\c
" Map ctrl-e for Extradite plugin
map <C-e> :Extradite!<CR>
" }}}
" {{{ Functions
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
function RemoveHtml()
%s#<[^>]\+>##g
endfunction
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()
function! Tab_Or_Complete()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endif
endfunction
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
" }}}
" {{{ Vundle
"set nocompatible " be iMproved
filetype off " required!
"set rtp+=~/.vim/bundle/vundle/
set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#rc()
call vundle#begin()
"Bundle 'gmarik/vundle'
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" My Bundles here:
"
" original repos on github
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'L9'
Plugin 'FuzzyFinder'
"Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'flazz/vim-colorschemes'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'takac/vim-commandcaps'
Plugin 'scrooloose/syntastic'
Plugin 'mattn/emmet-vim'
Plugin 'pangloss/vim-javascript'
Plugin 'stephpy/vim-php-cs-fixer'
Plugin 'int3/vim-extradite'
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'jamessan/vim-gnupg'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required!
" }}}
set rtp+=/home/niko/code/powerline/powerline/bindings/vim
let g:Powerline_symbols = 'fancy'
" Use 256 colours (Use this setting only if your terminal supports 256 colours)
set t_Co=256
set clipboard=unnamedplus
colorscheme tuutti
" Search files with unite.vim
nnoremap <space>p :Unite -start-insert file_rec/async:!<cr>
nnoremap <leader>s :Unite -start-insert buffer<cr>