-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
492 lines (339 loc) · 11.7 KB
/
.vimrc
File metadata and controls
492 lines (339 loc) · 11.7 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
" https://github.com/brandon-wallace
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Do not make vim compatible with vi.
set nocompatible
" Allow plugins to be used.
filetype plugin indent on
" Use syntax highlighting.
syntax on
" Always leave 10 rows below cursor.
set scrolloff=10
" Display a column with relative number column.
set relativenumber
" Add numbers to the lines.
set number
" Show cursor line.
set cursorline
" Show cursor column.
set cursorcolumn
" Set title of window to the name of the file.
set title
" Backup files.
set backup
" Backup directory.
set backupdir=~/.vim/backup/
" Hide mouse when typing.
set mousehide
" Check to see if an external file has changed.
set autoread
" Split window with cursor in bottom window.
set splitbelow splitright
" Leave windows uneven after split or close.
set noequalalways
" Switch buffers without saving.
set hidden
" Show error bell visually.
set visualbell
" Set the text width.
set textwidth=80
" Allow backspacing to work as expected.
set backspace=indent,eol,start
" Tabbing over moves four spaces.
set tabstop=4
" Number of spaces to use in automatically indent.
set shiftwidth=4
" Copy indent from current line when starting a new line.
set autoindent
" Use space characters instead of tabs.
set expandtab
" Incremental search an you type.
set incsearch
" Ignore capital letters during search.
set ignorecase
" Override the ignorecase option if searching for captial letters.
set smartcase
" Show the line and column position of cursor.
set ruler
" Show partial command in the last line of the screen.
set showcmd
" Show the mode in the last line.
set showmode
" Show matching words.
set showmatch
" Tenths of a second to show matching brackets.
set matchtime=2
" Use highlighting when doing a search.
set hlsearch
" Change the command history (default=20).
set history=1000
" If using a fast terminal.
set ttyfast
" Set the character enconding when writing file.
set fileencoding=utf-8
" Set the character encoding.
set encoding=utf-8
" Show auto complete menus.
set wildmenu
" Make wildmenu behave like bash completion.
set wildmode=list:longest
" Ignore files with these extentions.
set wildignore=*.odt,*.doc*,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.JPG,*.exe,*.bmp,*.flv,*.gz,*.tgz,*.zip,*.iso,*.gzip,*.mov,*.xz,*.tar,*.img,*.docx,*.xlsx,*.xls
" Temporary files.
set directory=/tmp
" Where the backups are stored.
set backupdir=~/.vim/backup
" Enable Python syntax highlighting features.
let python_highlight_all = 1
"PLUGINS ----------------------------------------------------------------- {{{
" Specify a directory for plugins.
" Avoid using standard Vim directory names like 'plugin'.
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes!!
Plug 'preservim/nerdtree'
Plug 'davidhalter/jedi-vim'
Plug 'https://github.com/vim-syntastic/syntastic.git'
Plug 'https://github.com/airblade/vim-gitgutter.git'
Plug 'preservim/nerdcommenter', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown'}
" Initialize plugin system.
call plug#end()
" Instant-Markdown settings.
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
let g:instant_markdown_allow_external_content = 1
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_mermaid = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
" Recommended Syntastics settings.
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Check syntax for python3 rather than python2.
let g:syntastic_python_python_exec = '/usr/bin/python3'
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
" }}}
" MAPPINGS --------------------------------------------------------------- {{{
" Set the leader to '-' instead of the default '\'.
let mapleader = "-"
" Set localleader to \.
let maplocalleader = "\\"
" Enable syntax highlighting in markdown code blocks.
let g:markdown_fenced_languages = ['html', 'python', 'css', 'vim', 'rust', 'c']
" Toggle set paste.
inoremap <F4> <esc>:set paste!<cr>i
nnoremap <F4> :set paste!<cr>
" Turn off search highlighting.
nnoremap <silent> <localleader>\ :nohlsearch<cr>
" Map ii to <Esc> only while in insert mode.
inoremap ii <Esc>
" Map <space> to ':'.
nnoremap <space> :
" Press <leader>- to go back to the last cursor position.
nnoremap <leader>- ``
" Open new lines without going into insert mode.
nnoremap <leader>o o<esc>
nnoremap <leader>O O<esc>
" Print file from a Linux machine.
" View available printers: lpstat -v
" Set default printer: lpoptions -d <printer_name>
nnoremap <silent> <leader>p :%w !lp<cr>
" Easy brackets.
inoremap <leader>' ''<esc>i
inoremap <leader>" ""<esc>i
inoremap <leader>( ()<esc>i
inoremap <leader>[ []<esc>i
inoremap <leader>{ {}<esc>i
inoremap <leader>< <><esc>i
" Center the cursor when moving to the next word.
nnoremap n nzz
nnoremap N Nzz
" Map <F3> to nerdtree toggle.
nnoremap <F3> :NERDTreeToggle ~/bin<cr>
" Have nerdtree ignore certain files.
let NERDTreeIgnore=['\.jpg$', '\.mp4$', '\.zip$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.svg$', '\.gif$', '\.tar$', '\.gz$', '\.xz$', '\.bz2$', '\.db$']
" Yank from cursor to the end of line.
nnoremap Y y$
" Select all text in buffer.
noremap <leader>a ggVG
" Press -v to edit .vimrc.
nnoremap <leader>v :e $MYVIMRC<cr>
" Press -s to source the .vimrc file.
nnoremap <leader>s :w<CR>:source $MYVIMRC<cr>
" See the fonts available on the system.
" syntax - :set guifont=Hack\ Bold\ 12.
nnoremap <leader>f :set guifont=*<cr>
" Press -S to check spelling in current buffer.
nnoremap <Leader>S <ESC>:setlocal spell spelllang=en_us<CR>
" Run the Python script by pressing F5.
nnoremap <f5> :w <CR>:!clear <CR>:!python3 % <CR>
" Run the Bash script by pressing F6.
nnoremap <f6> :w <CR>:!clear <CR>:!bash % <CR>
" Run make by pressing F7.
nnoremap <f7> :make
" Paste a block of code without formatting it.
nnoremap <mousemiddle> <esc>"*P
" Easy navigate the split view.
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Resize split windows using arrow keys.
noremap <c-up> <c-w>+
noremap <c-down> <c-w>-
noremap <c-left> <c-w>>
noremap <c-right> <c-w><
" Setting for netrw.
"let g:netrw_banner = 0
"let g:netrw_liststyle = 3
"let g:netrw_browse_split = 4
"let g:netrw_altv = 1
"let g:netrw_winsize = 20
" }}}
" VIMSCRIPT FILE SETTINGS ------------------------------------------------ {{{
" Use the marker method of folding.
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" Turn on cursorline and cursorcolumn only in active window.
augroup cursor_off
autocmd!
autocmd WinLeave * set nocursorline nocursorcolumn
autocmd WinEnter * set cursorline cursorcolumn
augroup END
" Auto load a template for a new file if one exists.
augroup filetype_html
autocmd!
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
augroup END
" Set indentation of HTML to 2 spaces.
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab
" If vim version is equal to or greater than 7.3 enable undofile.
if version >= 703
set undodir=~/.vim/backup
set undofile
set undoreload=10000
endif
if has("gui_running")
" Set the background tone.
set background=dark
" Set the color scheme.
colorscheme pablo
" Set font to DejaVu Sans Mono 10
set guifont=Hack\ Regular\ 12
" Hide the toolbar.
set guioptions-=T
" Hide the the left-side scroll bar.
set guioptions-=L
" Hide the the left-side scroll bar.
set guioptions-=r
" Hide the the menu bar.
set guioptions-=m
" Hide the the bottom scroll bar.
set guioptions-=b
" Map the F4 key to toggle the menu, tool, and scroll bar.
nnoremap <F4> :if &guioptions=~#'mTr'<Bar>
\set guioptions-=mTr<Bar>
\else<Bar>
\set guioptions+=mTr<Bar>
\endif<CR>
endif
" }}}
"STATUS LINE ------------------------------------------------------------ {{{
" Set colors for the status line.
hi User0 ctermbg=black ctermfg=yellow guibg=black guifg=yellow gui=bold
hi User1 ctermbg=blue ctermfg=black guibg=white guifg=blue gui=bold
" Clear status line when vimrc is reloaded.
set statusline=
" White on blue.
set statusline+=%0*
" Full path to the file.
set statusline+=\ %F
" Modified flag.
set statusline+=\ %M
" Blue on white.
set statusline+=\ %1*
" File type.
set statusline+=\ %Y
" Read only.
set statusline+=\ %R
" White on blue.
set statusline+=\ %0*
" Show the buffer number
set statusline+=\ buff:\ %n
" Blue on white.
set statusline+=\ %1*
" Ascii.
set statusline+=\ %b
" White on blue.
set statusline+=\ %0*
" Hex.
set statusline+=\ 0x%B
" Blue on white.
set statusline+=\ %1*
" Color.
set statusline+=%#warningmsg#
" Syntastic status line flag.
" set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Blue on white.
set statusline+=%1*
" Split the left from the right.
set statusline+=%=
" White on blue.
set statusline+=\ %0*
" Show the total number of lines in the file.
set statusline+=\ lines:\ %L
" Blue on white.
set statusline+=\ %1*
" Show the row the cursor is on.
set statusline+=\ row:\ %l
" Blue on white.
set statusline+=\ %0*
" Show the column the cursor is on.
set statusline+=\ col:\ %c
" Blue on white.
set statusline+=\ %1*
" Show the lenth of the line.
set statusline+=\ percent:\ %p%%
" White on blue.
set statusline+=\ %0*
" Show the status on the second to last line.
set laststatus=2
" }}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""