-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
162 lines (130 loc) · 4.08 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
" Machine-specific configs
" Enable modern Vim features not compatible with Vi spec.
set nocompatible
try
source /usr/local/google/home/tayo/.vimrc_google
catch
" No machine-specific vimrc..
endtry
" Local configs on a given machine
try
source ~/.vimrc_local.vim
catch
endtry
let mapleader=","
"Colors
set t_Co=256 "enable 256 color support in vim
set termguicolors
let g:lucius_style="dark"
let g:moria_style="light" " white, light, dark, black
let g:inkpot_black_background=0
set bg=dark
" colors
" light: moria_tayo,moria,papercolor,lunaperche,gruvbox
" dark: gruvbox,habamax,jellybeans,lucius,papercolor,wombat256,xoria256,zenburn256
syntax on
color moria
"set background=dark
set tabstop=2
set shiftwidth=2
set cindent
"set smartindent "apparently deprecated..
set autoindent
set showmatch "match parentheses
set matchtime=3
set expandtab "change tabs into spaces
set incsearch "searches in realtime as you type
set ruler
set hlsearch
set title "set term title to filename, etc
set textwidth=80
set wrap
set modeline
set ls=2
set number "line numbers
"set mouse=a "enable mouse usage
"
let g:python_recommended_style=0 " Use yapf for formatting
"set paste "paste things without worrying about indenting 'nopaste' to turn off
set pastetoggle=<F2>
set cursorline "highlight line containing the cursor
autocmd WinEnter * set cursorline "only active window shows cursor line
autocmd WinLeave * set nocursorline
set tags=./tags;/
set wildmenu wildmode=longest:full
"Status line: configure this better
"set statusline=%.100F
"set foldmethod=indent
"set foldminlines=24
"set foldnestmax=4
"Keyboard Mappings
"=================
command Bgd execute "set bg=dark"
command Bgl execute "set bg=light"
command FC execute "FormatCode"
" the following does not work with a range..
command FL execute "FormatLines"
"use CTRL-N to remove highlighted search terms
nmap <silent> <C-N> :silent noh<CR>h
"CTRL-[J|K|H|L] to move between windows
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
"JK or KJ can be used to exit insert mode
inoremap jk <esc>
inoremap kj <esc>
"CTRL-P: open file under cursor in new split window
nnoremap <C-P> <C-W>f
"CTRL-A is useful for tmux. I never use the number increment.
map <C-a> <Nop>
" filetype on
autocmd FileType cc,c,cpp,h :set cindent
autocmd FileType make :set noexpandtab "use hard tabs in Makefiles
autocmd FileType perl :hi Comment ctermfg=Blue
autocmd FileType tex :map <silent> <C-V> :s/^/%/<CR><C-N><CR>
autocmd Filetype stata :set ft=sh
" set wfh (make window height static), wfw (window width static)
"autocmd FileType tex :map <silent> <C-?> :s/^/%/<CR><C-N><CR>
" Exit insert mode
inoremap jk <esc>
inoremap kj <esc>
":set cinoptions=(0,1N,g2,h2,:2,=2
" automatically change working dir to that of current file
if exists('+autochdir')
set autochdir
else
autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
endif
let g:netrw_liststyle=3 "use hierarchical listing in netrw
let g:netrw_browse_split=4 "open new file in preview window
let g:netrw_altv=1 "open new file in vertical split (autochdir focuses there)
:set noea
:set nosplitright
"au BufRead,BufNewFile *.maxj set filetype=java "maxeler maxj files are java
au BufRead,BufNewFile *.cu set filetype=c "use C-style options for CUDA files
au BufRead,BufNewFile *.ts set filetype=javascript "TypeScript == JavaScript
"set spell "turn on spell-checking
"Gvim options
if has("gui_running")
":set guifont=Monospace\ 10
":set guifont=Noto\ Mono\ 12
if has('mac')
:set guifont=Menlo\ Regular:h12
:set guioptions+=k "Keep window size when resizing
elseif has('unix')
:set guifont=Ubuntu\ Mono\ 12
endif
set lines=50 columns=120
:set guioptions-=m "remove menubar (File, Edit, etc)
:set guioptions-=T "remove toolbar
:set guioptions-=r "remove right-hand scrollbar
:set guioptions-=L "remove left-hand scrollbar
endif
set vb t_vb= "turn off all audible bells etc
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
command! TrimWhitespace call TrimWhitespace()