-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
executable file
·285 lines (220 loc) · 7.06 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
call plug#begin()
Plug 'bling/vim-airline'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'pangloss/vim-javascript'
Plug 'othree/yajs'
Plug 'mxw/vim-jsx'
Plug 'rking/ag.vim'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'Xuyuanp/nerdtree-git-plugin'
call plug#end()
let g:airline_theme='solarized'
" Turn on syntax highlighting
syntax on
" powerline
" python from powerline.vim import setup as powerline_setup
" python powerline_setup()
" python del powerline_setup
" Enable loading filetype and indentation plugins
filetype plugin indent on
" more useful
set nocompatible
" Set the vim color theme to Soloarized
syntax enable
set background=dark
let g:solarized_termtrans = 1
colorscheme solarized
" Line numbers
set number
set title
" Turn off line wrapping
set nowrap
set smarttab
set expandtab
set autoindent
set smartindent
set nostartofline
set noshowmode
set formatoptions=
set formatoptions+=c " Format comments
set formatoptions+=r " Continue comments by default
set formatoptions+=o " Make comment when using o or O from comment line
set formatoptions+=q " Format comments with gq
set formatoptions+=n " Recognize numbered lists
set formatoptions+=2 " Use indent from 2nd line of a paragraph
set formatoptions+=l " Don't break lines that are already long
set formatoptions+=1 " Break before 1-letter words
" Write contents of the file, if it has been modified, on buffer exit
set autowrite
" Allow backspacing over everything
set backspace=indent,eol,start
" Insert mode completion options
" set completeopt=menu,longest,preview
" Use UTF-8 as the default buffer encoding
set enc=utf-8
" Remember up to 100 'colon' commmands and search patterns
set history=100
" Remember up to 1000 undos
set undolevels=1000
" Remember better history
set hidden
" Enable incremental search
set incsearch
" Always show status line, even for one window
set laststatus=2
" Jump to matching bracket for 2/10th of a second (works with showmatch)
set matchtime=2
" Don't highlight results of a search
set nohlsearch
" Enable CTRL-A/CTRL-X to work on octal and hex numbers, as well as characters
set nrformats=octal,hex,alpha
" Show line, column number, and relative position within a file in the status line
set ruler
" Scroll when cursor gets within 3 characters of top/bottom edge
set scrolloff=3
" Round indent to multiple of 'shiftwidth' for > and < commands
set shiftround
" Use 2 spaces for (auto)indent
set shiftwidth=2
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
" When a bracket is inserted, briefly jump to a matching one
set showmatch
" Don't request terminal version string (for xterm)
set t_RV=
" Use 2 spaces for <Tab> and :retab
set tabstop=2
" Use 2 spaces for <Tab> while performing editing operations, like insert a
" tab or using <BS>
set softtabstop=2
" Write swap file to disk after every 50 characters
set updatecount=50
" Remember things between sessions
"
" '20 - remember marks for 20 previous files
" \"50 - save 50 lines for each register
" :20 - remember 20 items in command-line history
" % - remember the buffer list (if vim started without a file arg)
" n - set name of viminfo file
set viminfo='20,\"50,:20,%,n~/.viminfo
" Go back to the position the cursor was on the last time this file was edited
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
" Highlight trailing whitespace
highlight WhitespaceEOL ctermbg=red guibg=red
autocmd BufWinEnter * match WhitespaceEOL /\s\+$/
" Highlight .json
autocmd BufNewFile,BufRead *.json set ft=json
" Highlight .sass
autocmd BufNewFile,BufRead *.scss set ft=css
"------------------------------------------------------------------------------
" buftabs.vim Configuration
"------------------------------------------------------------------------------
" Only print the filename of each buffer
:let g:buftabs_only_basename=1
" Show the buftabs in the statusline
" :let g:buftabs_in_statusline=1
" Highlight the active buffer name in the buftab
" :let g:buftabs_active_highlight_group="Visual"
"------------------------------------------------------------------------------
" KEY MAPPINGS
"------------------------------------------------------------------------------
" Various shortcuts for working with tabs
map ,t :tabnew
map ,d :tabprev<CR>
map ,f :tabnext<CR>
" Shortcuts for working with buffers
map ,bn :bnext<CR>
map ,bp :bprev<CR>
map ,bd :bdelete
map ,bl :buffers<CR>
map ,b :buffer
" NERD Tree
map ,<TAB>r :NERDTreeMirror<CR>
map ,<TAB>e :NERDTreeToggle<CR>
" Toggle line numbers
map ,# :set nu<CR>
map ,## :set nonu<CR>
" Toggle line wrapping
map ,w :set wrap<CR>
map ,ww :set nowrap<CR>
" Toggle paste
map ,pa :set paste<CR>
map ,npa :set nopaste<CR>
" New a new line? BR below...
map brb o<ESC>k
" New line above...
map bra O<ESC>j
" Search and replace
map ,sr :%s/
" g + direction for window split change. This beats the hell out of CTRL + W + direction
map g <C-w>
" Ensure gg still takes me to the top
map gg :1<CR>
" Open tag in new tab...
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" Or vertical split
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" Faster ctrlp lookup
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|node_modules|build|reports|screenshots)$',
\ }
let g:ctrlp_extensions = ['tag', 'buffertag', 'dir']
" make some brackets
imap {<cr> {<cr>}<c-o>O
" Syntastic js
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_aggregate_errors=1
let g:syntastic_javascript_checkers=['jsxhint']
let g:syntastic_json_checkers=['jsonlint']
let g:syntastic_html_tidy_ignore_errors=['proprietary attribute']
" immediate escape
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
" json formatting
function! FormatJSON()
:%!python -m json.tool
endfunction
" remove whitespace
function! RemoveWhitespace()
if !&binary && &filetype != 'diff'
normal mz
normal Hmy
%s/\s\+$//e
normal 'yz<CR>
normal `z
endif
endfunction
" window splits like a boss
set winheight=30
set winminheight=5
" search even better
function! FindAll(stringToFind)
:execute " grep -srnw --binary-files=without-match --exclude-dir='node_modules|build' . -e " . a:stringToFind . " " | copen 33
endfunction
" auto source when this file is saved
autocmd bufwritepost .vimrc source $MYVIMRC
" mave swp files to a better place
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
set undodir=~/.vim/undo
"Persistent undo
set undofile
" JSX in js files
let g:jsx_ext_required = 0
" folding
set foldenable
set foldlevelstart=10
set foldnestmax=10
set foldmethod=indent