-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot.vimrc
242 lines (193 loc) · 6.03 KB
/
dot.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
" Assume we're running with a black on white screen.
set background=light
" Run in vim-mode instead of strict vi-mode.
set nocompatible
" Keep files opened in hidden buffers even if they aren't visible.
set hidden
" Expand tabs into spaces.
set expandtab
" Shift 4 spaces when using shift commands.
set shiftwidth=4
" Actual tab characters are shown as 4 spaces.
set tabstop=4
" Don't add two spaces when joining lines with punctuation.
set nojoinspaces
" Keep indentation from line to line.
set autoindent
" Increase indentation after open-braces and match close-brace indentation to
" their open-brace indentations.
set smartindent
" Don't increase indent after any special words (for, while, do, etc.).
set cinwords=
" Disable smartindent's unindentation of lines starting with #
inoremap # X#
" Tries to match tabbing with the shiftwidth.
set smarttab
" Allows backspace to work in all situations
set backspace=indent,eol,start
" Don't treat the first non-blank character as the start of the line, treat
" column 0 as the start of the line.
set nostartofline
" Ignore case for searches.
set ignorecase
" Makes mixed-case searches be case-sensitive, but leaves lower-case searches
" case-insensitive.
set smartcase
" Automatically jump to where the search matches as it is being typed.
set incsearch
" Highlight searches by default.
set hlsearch
" Turns on syntax highlighting.
syn enable
" Briefly jumps to matching brackets when the closing bracket is typed.
set showmatch
" Try to keep 2 extra lines of context at the top and bottom of the screen.
set scrolloff=2
" Makes long lines not break mid-word
" set linebreak
" Underline a line at or past 80 characters.
" :hi LineTooLong cterm=underline
" :au BufWinEnter * let w:m2=matchadd('LineTooLong', '\%>80v.\+', -1)
" Status line setup.
set ruler
set laststatus=2
set statusline=%<%f\ %{&ff}%R%M%=%l:%c\ %p%%
" Show commands and selection area size
set showcmd
" Tell vim we have a 16-color terminal.
set t_Co=16
" Updates the title of compatible term programs.
set title
set titlestring=%f
" Turns off any audible or visible bell.
set visualbell t_vb=
autocmd GUIEnter * set vb t_vb=
set noeb
set novb
" Turn on mouse mode.
set mouse=
" Font for GUI versions.
set guifont=Consolas:h14
" e = gui tabs, g = menu items greyable, m = menu bar, r = right scrollbar
set guioptions=egm
" Modified, file name, full file path
set guitablabel=%M\ %t\ %F
" Nicer file name tab-completion.
set wildmenu
" Let bash aliases, etc. work.
let $BASH_ENV = "~/.gholtbashrc"
" Maps \b to list the current buffers. Then you can type a buffer number, or a
" partial buffer name and hit tab, then enter to switch to it.
map <Leader>b :ls<CR>:b<Space>
" Maps \cd to change the current directory to the same directory as the file
" in the current buffer.
map <Leader>cd :cd %:p:h<CR>
" Python: Maps \l to run (lint) flake8 on the current file.
" function! GHolt_lint()
" set lazyredraw
" cclose
" let l:grepformat_orig=&grepformat
" let l:grepprg_orig=&grepprg
" let &grepformat="%f:%l:%c: %m\,%f:%l: %m"
" let &grepprg="flake8"
" silent grep %
" let &grepformat=l:grepformat_orig
" let &grepprg=l:grepprg_orig
" cwindow
" set nolazyredraw
" redraw!
" if getqflist() == []
" echo "flake8 clean"
" endif
" endfunction
" map <Leader>l :call GHolt_lint()<CR>
" Python: Maps \L to run (lint) flake8 from the current working directory.
" function! GHolt_lintcwd()
" set lazyredraw
" cclose
" let l:grepformat_orig=&grepformat
" let l:grepprg_orig=&grepprg
" let &grepformat="%f:%l:%c: %m\,%f:%l: %m"
" let &grepprg="flake8"
" silent grep .
" let &grepformat=l:grepformat_orig
" let &grepprg=l:grepprg_orig
" cwindow
" set nolazyredraw
" redraw!
" if getqflist() == []
" echo "flake8 clean"
" endif
" endfunction
" map <Leader>L :call GHolt_lintcwd()<CR>
" Golang: Maps \g to run: go install
function! GHolt_gobuild()
set lazyredraw
cclose
let l:grepformat_orig=&grepformat
let l:grepprg_orig=&grepprg
let &grepformat="%-G#\ %.%#,%A%f:%l:%c:\ %m,%A%f:%l:\ %m,%C%*\\s%m,%-G%.%#"
let &grepprg="go install ./..."
silent grep
let &grepformat=l:grepformat_orig
let &grepprg=l:grepprg_orig
cwindow
set nolazyredraw
redraw!
if getqflist() == []
echo "go install returned clean"
endif
endfunction
map <Leader>g :call GHolt_gobuild()<CR>
" Golang: Maps \G to run: gogo (which is go vet, test, install)
function! GHolt_gobuildfull()
set lazyredraw
cclose
let l:grepformat_orig=&grepformat
let l:grepprg_orig=&grepprg
let &grepformat="%-G#\ %.%#,%A%f:%l:%c:\ %m,%A%f:%l:\ %m,%C%*\\s%m,%-G%.%#"
let &grepprg="gogo"
silent grep
let &grepformat=l:grepformat_orig
let &grepprg=l:grepprg_orig
cwindow
set nolazyredraw
redraw!
if getqflist() == []
echo "go build, vet, test, install returned clean"
endif
endfunction
map <Leader>G :call GHolt_gobuildfull()<CR>
" Maps \p to toggling paste and nopaste modes. This lets you turn off
" auto-indenting, etc. while pasting in a big block of text.
nnoremap <Leader>p :set invpaste paste?<CR>
" Maps \s to toggle spellcheck mode.
nnoremap <Leader>s :set invspell spell?<CR>
" Maps \w to toggle textwidth between 72 and 0.
function! GHolt_tw()
if &tw == 0
set tw=72
echo "tw=72"
else
set tw=0
echo "tw=0"
endif
endfunction
nnoremap <Leader>w :call GHolt_tw()<CR>
" Gets folding set up but turned off by default.
" zi = toggle on/off
" za = toggle fold under cursor, one level
" zA = toggle fold under cursor, all levels
" zC = close fold under cursor -- visual select area to close folds within
" Probably easier ways to do things, but the above is what I've become used to.
set foldmethod=syntax
set nofoldenable
" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
" General Tips
"
" Replace double blank lines with single blank lines
" :%s/\n\{3,}/\r\r/e
" To list spelling alternatives
" z=
" Look for long lines
" :match Error /\%>80v/