-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
225 lines (171 loc) · 5.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
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
" Author:
" Jonathan Ellington, heavy inspiration from https://github.com/amix/vimrc
"
" Requires:
" vim-plug plugin manager
"
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
"
" Sections:
" 1. General
" 2. Plugins
" 3. User Interface
" 4. Colors, fonts
" 5. Text, tab, indent stuff
" 6. Moving around, tabs, buffers
" ------------------------------------------------------------------------
" General
" ------------------------------------------------------------------------
" Filetype plugins
filetype plugin on
filetype indent on
" Swap mapleader and comma
let mapleader = ","
" Map space to colon, for convenience
noremap <Space> :
" Keep 200 lines of command line history
set history=200
" First search directory of file, then cwd, then all the way up to root
set tags=./tags;,.git/tags;
" ------------------------------------------------------------------------
" Plugins
" ------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
Plug 'git://github.com/altercation/vim-colors-solarized.git'
Plug 'junegunn/vim-easy-align'
Plug 'kien/ctrlp.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'valloric/youcompleteme'
Plug 'vhda/verilog_systemverilog.vim'
Plug 'majutsushi/tagbar'
Plug 'bling/vim-airline'
Plug 'scrooloose/syntastic'
" Decommissioned
" Plug 'godlygeek/tabular'
" Plug 'tomtom/tcomment_vim'
call plug#end()
" Tagbar
nmap <Leader>t :TagbarToggle<CR>
" vim-easy-align
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" ------------------------------------------------------------------------
" User Interface
" ------------------------------------------------------------------------
" Turn on wildmenu (enhanced command-line completion)
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win32") || has("win64")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
end
" Line numbers
set number
" Always show current position
set ruler
" Hidden buffers (can leave modified buffers)
set hidden
" Backspace over things it should backspace over
set backspace=indent,eol,start
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Be smart about cases when searching
set smartcase
" Highlight search results
set hlsearch
" Don't redraw while executing macros (for performance)
set lazyredraw
" Show matching brackets, parens, curlys
set showmatch
" Lines before scrolling with j/k
set scrolloff=5
" Shorter timeout for keycode sequences
set noerrorbells
set novisualbell
set timeoutlen=500
" ------------------------------------------------------------------------
" Colors and Fonts
" ------------------------------------------------------------------------
" Enable syntax highlighting
syntax enable
" Extra GUI stuff
if has("gui_running")
set guioptions-=m
set guioptions-=T
endif
set background=light
try
colorscheme solarized
catch
endtry
" Use utf8 as standard encoding and en_us as standard language
set encoding=utf8
set spelllang=en_us
" ------------------------------------------------------------------------
" Text, tab, indent stuff
" ------------------------------------------------------------------------
" Use spaces instead of tabs
set expandtab
set smarttab
" 1 tab = 4 spaces
set shiftwidth=2
set tabstop=2
" Autoindent new lines
set autoindent
" Stop indents on shiftwidths (>,< cmds)
set shiftround
" Easy way to set tab spacing
nnoremap <leader>st :SetTabs<CR>
command! -nargs=* SetTabs call SetTabVals()
function! SetTabVals()
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
if l:tabstop > 0
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
endif
endfunction
" ------------------------------------------------------------------------
" Moving around, tabs and buffers
" ------------------------------------------------------------------------
" Easily change to previously used buffer
nnoremap <Leader><Tab> <C-^>
" Place cursor anywhere
set virtualedit=all
" Easy way to turn off highlighting
map <silent> <leader><cr> :noh<cr>
" Easy way to move around 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
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
" Display incomplete commands in the status line
set showcmd
" Always show statusline
set laststatus=2
" Full filename in statusline
set statusline=%F " full filename in statusline
" Easily edit vimrc file
nnoremap <silent> <leader>vw :e $MYVIMRC<CR>
nnoremap <silent> <leader>vt :tabedit $MYVIMRC<CR>
" Automatically source vimrc on write
if has ( "autocmd")
autocmd! BufWritePost $MYVIMRC source $MYVIMRC " auto-source on write
endif
" ------------------------------------------------------------------------
" Miscellaneous
" ------------------------------------------------------------------------