-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
243 lines (184 loc) Β· 6.94 KB
/
Copy pathvimrc
File metadata and controls
243 lines (184 loc) Β· 6.94 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
" β οΈ This comment will override any vim settings when editing this file. These
" particular settings cause vim to use tabs not spaces
" vim: tabstop=4:shiftwidth=4:autoindent:smartindent:noexpandtab:softtabstop=0:cino=g0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" βοΈ General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Vim behavior, not vi
" This must be first, because it changes other options as side effect
set nocompatible
" π Use pathogen to easily modify the runtime path to include all plugins under
" " the ~/.vim/bundle directory
filetype off " force reloading *after* pathogen loaded
call pathogen#helptags()
execute pathogen#infect()
" π Enable loading the plugin files and indent file for specific file types
filetype plugin indent on
" π Number of lines of history to remember
set history=1000
" β©οΈ Number of levels of undo history
set undolevels=1000
" π« Ignore these file extensions when completing names by pressing Tab
set wildignore+=*.swp,*.bak,*.class
" π€ Disable these characters as word dividers
set iskeyword+=_
" π Make searches case-insensitive, unless they contain upper-case letters
set ignorecase
set smartcase
" π― Virtual editing means that the cursor can be positioned where there is no
" actual character. This can be halfway into a tab or beyond the end of the
" line. Useful for selecting a rectangle in Visual mode and editing a table.
set virtualedit=all
" β« Allow backspacing over autoindent, line breaks (join lines), start of insert
set backspace=indent,eol,start
" πΎ Write the contents of the file, if it has been modified, after certain
" commands
set autowrite
" π Affects the output of :TOhtml
:let html_use_css = 1
:let use_xhtml = 1
" ποΈ store status information
set viminfo='1000,f1,<500,%
" π hide buffers instead of closing them
set hidden
" π« Don't write backup files
set nobackup
set noswapfile
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π¨ Theme/Colors
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark
" π‘ Switch syntax highlighting on, when the terminal has colors
if &t_Co > 2 || has("gui_running")
syntax on
endif
" π A 256 color scheme
if &t_Co >= 256 || has("gui_running")
colorscheme inkpot
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Visual cues
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π When a bracket is inserted, briefly jump to the matching one.
set showmatch
" π When there is a previous search pattern, highlight all its matches.
set hlsearch
" π Use emacs-like incremental search (find as you type)
set incsearch
" π¦ Strings to use in 'list' mode. Enable list mode with :set list
set listchars=tab:>-,trail:_,eol:$,nbsp:%,extends:#
" π No audio or visual bell
set novisualbell
set noerrorbells
" π Show the line and column number of the cursor position
set ruler
" π·οΈ Change the terminal's title
set title
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Text formatting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
" π Tabs, not spaces!
" set noexpandtab
" π€· But just in case I'm working on a file with a more evil form of indentation
set expandtab
" π C-indenting option to make public and private labels not increase the
" indentation level
set cino=g0
autocmd Filetype gitcommit setlocal spell textwidth=72
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" β¨οΈ Key mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ποΈ Toggle display of unprintable characters
:map <F3> :set list!<CR>
" π Toggle search highlighting
:map <F5> :set hls!<bar>set hls?<CR>
" π Ignore whitespace in diff views (vim -d file1 file2)
:map <F9> :set diffopt+=iwhite<CR>
" π Toggle paste mode. Everything is inserted literally - no indending
set pastetoggle=<F10>
" π’ Toggle line numbers
:map <F12> :set number!<CR>
" βοΈ Ctrl j/k to navigate horizontal splits
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
set wmh=0
" βοΈ Ctrl h/l to navigate vertical splits
map <C-H> <C-W>h<C-W><bar>
map <C-L> <C-W>l<C-W><bar>
set wmw=0
" π Don't use Ex mode, use Q for formatting. Wrap a block of text.
map Q gq
" π change the mapleader from \ to ,
let mapleader=","
" π± Use semi-colon instead of colon
nnoremap ; :
nnoremap <up> gk
nnoremap <down> gj
" βοΈ Clear highlighted searches
nmap <silent> ,/ :nohlsearch<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Misc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Show the diffs between this buffer and the saved version of the file
function! s:DiffWithSaved()
let filetype=&ft
diffthis
" new | r # | normal 1Gdd - for horizontal split
vnew | r # | normal 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! Diff call s:DiffWithSaved()
" π When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π Stuff unique to my plug-ins/set-up
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" π― Load matchit (% to bounce from do to end, etc.)
runtime! macros/matchit.vim
" π³ Tab completion
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
" π·οΈ toggle the taglist window.
nnoremap <silent> <F8> :TlistToggle<CR>
" β‘οΈ cursor moves to the taglist window after opening the taglist window
let Tlist_GainFocus_On_ToggleOpen = 1
" πͺ exit Vim if only the taglist window is currently opened
let Tlist_Exit_OnlyWindow = 1
" π·οΈ For use with ctags - most people won't need this
set tags=./tags,tags,../tags,../../tags,../../../tags,../../../../tags
" π Start diff mode with vertical splits (unless explicitly specified otherwise).
set diffopt+=vertical
" π‘ Highlight whitespace at the end of the line in ugly yellow
match Todo /\s\+$/
" π Don't ignore case in search patterns.
set noignorecase
" π tell VIM to always put a status line in, even if there is only one window
set laststatus=2
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
au BufRead,BufNewFile *.g4 set filetype=antlr4
" https://stackoverflow.com/a/37884871
set timeoutlen=1000
set ttimeoutlen=0