-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
137 lines (110 loc) · 4.12 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
set nocompatible
set shiftwidth=4
set wrap
"set smarttab
"set tw=80
" always show a status line at the bottom, similar to when using Ctrl-G
"set laststatus=2
syntax on
"set number
set background=dark
"set background=light
set hlsearch
set autoindent
set ruler
set tabstop=4
set expandtab
inoremap /* /* */<ESC>hhi
inoremap ( ()<ESC>i
"inoremap [ []<ESC>i
inoremap " ""<ESC>ha
inoremap ' ''<ESC>ha
inoremap { {}<ESC>ha
inoremap [ []<ESC>ha
inoremap ( ()<ESC>:let leavechar=")"<CR>i
imap <C-j> <ESC>:exec "normal f" . leavechar<CR>a
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
map <C-n> :set number<CR>
map <C-m> :set nonumber<CR>
" Ctrl-l to set file highlighting to system logs
map <C-l> :set filetype=messages<CR>
" Macros
function! Manpage()
execute "!man " . expand("<cword>")
endfunction
map <F8> : call Manpage()<CR><CR>
map! <F8><ESC>: call Manpage()<CR><CR>a
" use _( to bracket previously visually selected text.
vnoremap _( <ESC>`>a)<ESC>`<i(<ESC>
" highlight lines longer than 80 characters
" highlight OverLength ctermbg=red ctermfg=white guibg=#592929
" match OverLength /\%81v.\+/
map <C-p> :match ErrorMsg '\%>80v.\+'<CR>
map <C-o> :match<CR>
" turn highlight of overlength lines on by default:
":match ErrorMsg '\%>80v.\+'
" Highlight trailing whitespace:
:autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
:highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
:match ExtraWhitespace /\s\+$/
" log files syntax highlighting:
" This creates a keyword ERROR and puts it in the highlight group called logError
:syn keyword logError ERROR
:syn keyword logDEBUG DEBUG
:syn keyword logINFO INFO
" This creates a match on the date and puts in the highlight group called logDate. The
" nextgroup and skipwhite makes vim look for logTime after the match
:syn match logDate /^\d\{4}-\d\{2}-\d\{2}/ nextgroup=logTime skipwhite
" This creates a match on the time (but only if it follows the date)
:syn match logTime /\d\{2}:\d\{2}:\d\{2},\d\{3}/
" Now make them appear:
" Link just links logError to the colouring for error
hi link logError Error
hi link logDebug Debug
hi link logINFO Comment
" automatically break up lines that are more than 80 characters
"setlocal textwidth=80
" F4 to grep for word under cursor
map <F4> :execute " grep -srnw --exclude=tags --binary-files=without-match --exclude-dir=.git . -e " . expand("<cword>") . " " <bar> cwindow<CR>)
"" Backup and undo settings
set backupdir=~/.vim/backup// "location of backups
set directory=~/.vim/tmp// "location of swap files
set dir=~/.vim/tmp// "location of swap files
set undofile
set undodir=~/.vim/undodir//
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=1000 "maximum number lines to save for undo on a buffer reload
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
let hlstate=0
nnoremap <C-h> :if (hlstate%2 == 0) \| nohlsearch \| else \| set hlsearch \| endif \| let hlstate=hlstate+1<cr>
" Break up ssapp exception tracebacks
map <F2> :%s/\#012/\r/g<CR>
" tags shortcut:
" Ctrl-\ Open the definition in a new vertical split
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
""set cursorcolumn
"set cursorline
call plug#begin('~/.vim/plugged')
" Add maktaba and bazel to the runtimepath.
" (The latter must be installed before it can be used.)
Plug 'google/vim-maktaba'
Plug 'bazelbuild/vim-bazel'
Plug 'wellle/context.vim'
Plug 'bazelbuild/vim-ft-bzl'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Initialize plugin system
call plug#end()
" use 4-space, non-expanding tabs for Go, to match "go fmt"
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4