-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
233 lines (181 loc) · 5.57 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
set nocompatible
set belloff=all
set ambw=double "Windows WSL has a broken terminal that starts vim in replace mode. See https://superuser.com/questions/1284561/why-is-vim-starting-in-replace-mode
"map F1 to toggle search highlighting on and off
map <F6> :set hlsearch!<CR>
imap <F6> <ESC>:set hlsearch!<CR>a
map <F2> :!ctags -R .<CR>
"map <F7> :set syntax=c<CR>
"imap <F7> <ESC>:set syntax=c<CR>a
map <F7> :syntax reset<CR>
imap <F7> <ESC>:syntax reset<CR>a
" delete trailing whitespace
map <F5> :%s/\s\+$//g<CR>
imap <F5> <ESC>:%s/\s\+$//g<CR>a
set pastetoggle=<F2>
map <F3> :cp<CR>
map <F4> :cn<CR>
nnoremap <F9> :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
map <F12> :colorscheme github<CR>
imap <F12> <ESC>:colorscheme github<CR>a
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Diff resolution
map <C-,> :diffget LOCAL<CR>
map <C-.> :diffget REMOTE<CR>
imap <C-,> <ESC>:diffget LOCAL<CR>a
imap <C-.> <ESC>:diffget REMOTE<CR>a
" temporary
nnoremap <silent> ,p 0i[PRF] <ESC>
nnoremap <silent> ,r 0i[RW] <ESC>
nnoremap <silent> ,m 0i[MATLAB] <ESC>
" Enable 'in-column' up and down motion in INSERT mode on wrapped lines
imap <silent> <Up> <C-o>gk
imap <silent> <Down> <C-o>gj
" Enable 'in-column' up and down motion on wrapped lines
map <silent> <Up> gk
map <silent> <Down> gj
syntax on
" Cursor highlighting
set cursorline
" Folding
highlight Folded ctermbg=234 ctermfg=Gray
" Cursor
highlight CursorLine cterm=NONE ctermbg=234
" highlight active status line
highlight statusline ctermbg=22 ctermfg=16 cterm=NONE
highlight statuslinenc ctermbg=237 ctermfg=7 cterm=NONE
" split divide
highlight vertsplit ctermbg=237 ctermfg=237 cterm=NONE
" make the window title reflect the file being edited
set title
set titlestring=VIM:\ %F
set laststatus=2
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
" 4 characters for tabs, use spaces
set tabstop=4
set shiftwidth=4
set expandtab
" backspace should delete
set backspace=2
" Set backup location and enable
set backupdir=/home/matt/.vim/backup//,/tmp
set backup
set writebackup
" Set swap directory
set directory=/home/matt/.vim/swap//,/tmp
" Save undo history
set undofile
set undodir=/home/matt/.vim/undo//,/tmp
set undolevels=1000
set undoreload=10000
" filename tab complete
set wildmode=longest,list,full
" Set searching preferences
set incsearch " do incremental searching
set ignorecase
set smartcase
set showmatch
set nohlsearch
" Detect files that have changed
set autoread
au FocusGained,BufEnter * :checktime
au CursorHold,CursorHoldI * checktime
set showcmd " display incomplete commands
set comments=n:#,:%,fb:-,n:>nn:)
set comments+=b:\"
set esckeys
set fileformat=unix
set report=0
set shell=bash
set showmode
set nostartofline
set linebreak
set so=3
"set nospell
set foldenable
set foldmethod=indent
autocmd FileType c,cpp :set foldmethod=syntax
set foldlevel=0
set foldlevelstart=3
set foldnestmax=6
"#set termguicolors
set autochdir
set nowrap
set scrollopt+=hor
"set tags=tags;
set tags^=tags;
"set tags+=./.git/tags;.
let g:ctags_statusline=1
let generate_tags=1
"save/load fold state
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview
set autoindent
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
" Filetype for markdown
au BufNewFile,BufRead *.md set ft=markdown
" Highlight trailing whitespace
autocmd Filetype c,cpp,markdown match Error /\s\+$/
" Don't expand tabs in makefiles
autocmd FileType make setlocal noexpandtab
"" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
augroup filetypedetect
au BufRead,BufNewFile *.cl set filetype=c
augroup END
augroup filetypedetect
au BufRead,BufNewFile *.asm set filetype=hydra_asm
augroup END
" hide cursorline in non-active windows
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
" Highlight patterns that match where the cursor is
set updatetime=100
" highlight the word under cursor (CursorMoved is inperformant)
highlight WordUnderCursor cterm=underline gui=underline
autocmd CursorHold * call HighlightCursorWord()
function! HighlightCursorWord()
" if hlsearch is active, don't overwrite it!
let search = getreg('/')
let cword = expand('<cword>')
if match(cword, search) == -1
exe printf('match WordUnderCursor /\V\<%s\>/', escape(cword, '/\'))
endif
endfunction
function TurnOffCaps()
let capsState = matchstr(system('xset -q'), '00: Caps Lock:\s\+\zs\(on\|off\)\ze')
if capsState == 'on'
silent! execute ':!xdotool key Caps_Lock'
endif
endfunction
au InsertLeave * call TurnOffCaps()
"set colorscheme=parsec