-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
213 lines (180 loc) · 5.71 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
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-scripts/matchit.zip'
Plugin 'alvan/vim-php-manual'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdcommenter'
Plugin 'spf13/vim-markdown'
Plugin 'mattn/emmet-vim'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'groenewege/vim-less'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/taglist.vim'
Plugin 'sjl/gundo.vim'
Plugin 'vimwiki/vimwiki'
Plugin 'kchmck/vim-coffee-script'
Plugin 'endel/vim-github-colorscheme'
Plugin 'ap/vim-css-color'
Plugin 'thinca/vim-visualstar'
Plugin 'fugalh/desert.vim'
Plugin 'tomasr/molokai'
Plugin 'Valloric/YouCompleteMe'
Plugin 'majutsushi/tagbar'
Plugin 'haya14busa/incsearch.vim'
Plugin 'sjl/badwolf'
Plugin 'mileszs/ack.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'guns/vim-clojure-static'
Plugin 'tpope/vim-fireplace'
Plugin 'morhetz/gruvbox'
call vundle#end()
filetype plugin indent on
syntax on
" show matching variables on hover
":autocmd CursorMoved * silent! exe printf('match IncSearch /\<%s\>/', expand('<cword>'))
" general tip: when keeping a diary-like log file of "first I did this, then
" that", do :r !date to get a well formed timestamp before you start
" spellcheck commit messages
" zg => mark word as good
" z= => get suggestions for improvements
au BufNewFile,BufRead *.wiki,*.markdown,*.md,*.dox,COMMIT_EDITMSG,README,CHANGELOG,INSTALL setlocal spell
au BufNewFile,BufRead *.yml set ts=2 sw=2 expandtab
au BufNewFile,BufRead *.py set ts=4 sw=4 expandtab
au BufNewFile *.py 0r ~/.vim/template.py
au BufNewFile *.html 0r ~/.vim/template.html
au BufNewFile *.php 0r ~/.vim/template.php
" highlight trailing whitespace,
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au BufEnter,InsertLeave * match ExtraWhitespace /[^\t]\zs\t\+\|\s\+$\| \+\ze\t/
set background=dark
color gruvbox " (badwolf is nice in the winter, but in a light room.. go github) badwolf desert molokai
set autoindent
set copyindent
set cursorline
set backspace=indent,eol,start
set hidden
set history=1000
set laststatus=2
set nobackup
set modelines=0
set noerrorbells
set nostartofline
set nonumber
set showcmd
set colorcolumn=+1 " highlights the column after textwidth (80, usually)
set tabstop=8
set shiftwidth=8
set noexpandtab
set scrolloff=6
set undolevels=1000
set wildmenu
set ttyfast
set virtualedit+=block
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.o
" use gx on a URL
let g:netrw_list_hide= '.*\.so$,.*\.swp$,.*\.zip$,.*\.pyc$,.*\.o$'
let g:ycm_autoclose_preview_window_after_insertion = 1
" go up one visual line, not logic line
nnoremap j gj
nnoremap k gk
" stay in visual mode after indentation
vnoremap < <gv
vnoremap > >gv
set foldmethod=indent
au FileType gitcommit set nofoldenable
au FileType sass set tabstop=8 shiftwidth=8 noexpandtab
au FileType markdown set textwidth=80
let mapleader=","
" gundo.vim
nnoremap <leader>u :GundoToggle<CR>
" ctags
" install Exuberant ctags
" cd ~; ctags code
" # open a file
" # ctrl+] when cursor on variable
" # ctrl+t to return
" ,t to open overview of file
" more: http://vim.wikia.com/wiki/Browsing_programs_with_tags
set tags=tags,./tags,~/tags;/
nnoremap <leader>t :TagbarToggle<CR>
" search options
set gdefault
set hlsearch
set ignorecase
set smartcase
set incsearch
set showmatch
set statusline=%<%{getcwd()}/%f\ " Filename
set statusline+=\ %{fugitive#statusline()} " Git historyotness
set statusline+=\ %=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
nmap <leader>n :nohl<CR>
nmap <leader>a :Ack
nnoremap <leader>m :NERDTree<CR>
" incsearch: show all matches right away
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
" vimwiki
" auto_export generates html each time a buffer is saved
let g:vimwiki_list = [{
\ 'path': '~/vimwiki',
\ 'template_path': '~/vimwiki/style/',
\ 'template_default': 'template',
\ 'template_ext': '.html',
\ 'css_name': '~/vimwiki/style/style.css',
\ 'auto_export': 1
\ }]
" buf explorer
" after finding the buffer you want to switch to, :bN switches to buffer N
" or just <leader>b to go to next buffer
nnoremap <leader><leader> :ls<CR>
" save file accidentally opened without sudo
" from http://nvie.com/posts/how-i-boosted-my-vim/
cmap w!! w !sudo tee % >/dev/null<CR>
" restore cursor position next time the file is opened, from
" 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
" transform
" if(a)
" echo 'yes';
" to
" if(a) {
" echo 'yes';
" }
nnoremap <leader>f A {<esc>jo}<esc>
" S requires the vim-surround plugin
vmap <leader>vdd Sbivar_dump<esc>f(a__METHOD__." ".__FILE__.":".__LINE__, <esc>f)a;<esc>
inoremap <leader>vdd if(PHP_SAPI != 'cli' && !headers_sent()) header("HTTP/1.1 500 Internal Server Error");<esc>oecho "<pre>";<esc>ovar_dump(__METHOD__." ".__FILE__.":".__LINE__, );<esc>odie(1);<esc>k0f)i
inoremap <leader>cl console.log();<esc>F)i
fun! Op5JIRA()
let l:issue_id = expand("<cWORD>")
let l:issue_id = substitute(l:issue_id, '\D', '', 'g')
if !len(l:issue_id)
echo "You must have cursor over MON-123 or 123 to use Op5JIRA"
return
endif
call netrw#NetrwBrowseX("https://jira.op5.com/browse/MON-".l:issue_id, 0)
endfun
nnoremap gj :call Op5JIRA()<CR>
""" debugging tips:
""" http://vim.wikia.com
""" :command (list user defined commands)
""" :scriptnames (list loaded plugins)
""" vim -u NONE (run vim without plugins or vimrc)
""" vim -u NORC (run vim with plugins, without vimrc)
""" :echo g:colors_name <-- current scheme
""" :echo &ft <-- current filetype