-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
281 lines (227 loc) · 7.45 KB
/
vimrc
File metadata and controls
281 lines (227 loc) · 7.45 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
"Plugin manager:[https://github.com/junegunn/vim-plug] "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Content
"
" 0. General Options
" 1. Mouse and clipboard settings
" 2. Movement keys
" 3. Formatting options
" 4. Search options
" 5. Statusline modifications
" 6. Plugins
" 7. Functions
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"0. General options "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"If loop prevents mutliple calls to syntax on (can mess up highlighting)
if !exists("g:syntax_on")
syntax enable
endif
"Detect filetype
filetype on
"Reload vimrc
nnoremap <F5> :so $MYVIMRC<CR>
"Quick acces to vimrc
nnoremap <F6> :e $MYVIMRC<CR>
"Exit insert mode from homerow
inoremap jk <Esc>
"Require certain number of lines to be shown below/above cursor
set scrolloff=4
"Do not redraw screen whilst executing macros
set lazyredraw
"Dictate location of new windows after splits
set splitright
set splitbelow
"Disable conceal feature, thus not altering the LaTeX equation input
let g:tex_conceal = ""
"Enable simple copy/pasting from visual mode (when using vim GUI)
set guioptions+=Autoselect
"Folding method based on indent of code
set foldmethod=indent
set foldlevel=99
"Do not require save before switching buffers
set hidden
"Enable persistent undo (within each reboot)
"First create a tmp undo directory
let s:undoDir = "/tmp/.undodir_" . $USER
if !isdirectory(s:undoDir)
call mkdir(s:undoDir, "", 0700)
endif
let &undodir=s:undoDir
set undofile
"Use dracula color theme
syntax on
color dracula
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"1. Mouse and clipboard settings "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Enable mouse usage
set mouse=a
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"2. Movement keys "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Allow single j and k movements to treat wrapped lines separately.
""Strict linewise movement resumed when preceeded with a count.
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
"Remap H and L to SOF and EOL
nnoremap H ^
nnoremap L $
"------- Prevent use of arrow keys --------
""Normal mode arrow keys
"nnoremap <Left> :echo "No left for you!"<CR>
"nnoremap <Right> :echo "No right for you!"<CR>
"nnoremap <Up> :echo "No up for you!"<CR>
"nnoremap <Down> :echo "No down for you!"<CR>
"Visual mode arrow keys
"vnoremap <Left> :<C-u>echo "No left for you!"<CR>
"vnoremap <Right> :<C-u>echo "No right for you!"<CR>
"vnoremap <Up> :<C-u>echo "No up for you!"<CR>
"vnoremap <Down> :<C-u>echo "No down for you!"<CR>
""Insert mode arrow keys (doesn't work..?)
"inoremap <Left> <nop>
"inoremap <Right> <nop>
"inoremap <Up> <nop>
"inoremap <Down> <nop>
"Shortcuts to switch through buffers with ctrl
noremap <C-n> :bnext<CR>
noremap <C-m> :bprev<CR>
""Switch between open windows
noremap <C-j> <C-W><C-j>
noremap <C-k> <C-W><C-k>
noremap <C-h> <C-W><C-h>
noremap <C-l> <C-W><C-l>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"3. Formatting options "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Number current line, and use relative number lines elsewhere
set nu
set rnu
"Show existing tab with 4 spaces width
set tabstop=4
"Convert tabs to spaces
set expandtab
"When indenting with '>', use 4 spaces width
set shiftwidth=4
"How many spaces are used in insert mode
set softtabstop=4
"Maintain indent from current line to next line
set autoindent
"Wrapped lines follow indentation
" set breakindent
"Show lnewrapping by indicating \\ for wrapped line
set showbreak=\\\\\
" set textwidth=80
"Show vertical indicator at a textwidth of 80
set colorcolumn=88
set fileformat=unix
"Underline the current line
set cursorline
"Disable comment autowrapping, auto insertion of comment leader
autocmd FileType * set formatoptions -=cro
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"4. Search options "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set ignore case
set ic
"Highlight all matches when searching
set hlsearch
nnoremap <leader><space> :nohlsearch<CR>
"Search as characters are entered
set incsearch
"Enable autocompletion
"longest inserts the longest common text
"menu ensures a menu still pops up, even if only one selection is shown
set completeopt=longest,menuone
"Enables possible files to be listed when using tab completion with :e <filename-partial><<TAB>>
set wildmenu
set wildmode=full
"Allow fuzzy searching down through folders
set path+=**
"Recursively search for ctags file up to root folder until one is found
set tags+=./tags,tags;
"Easy acces to Explore and Sexplore
noremap <leader>e :Explore<cr>
noremap <leader>s :Lexplore<cr>
"Netrw options
"Restrict window size
let g:netrw_winsize = -28
"Remove netrw banner
let g:netrw_banner = 0
"Use tree style listing for files
let g:netrw_liststyle = 3
"Directories on top and files below
let g:netrw_sort_sequence = '[\/]$,*'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"5. Statusline modifications "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set laststatus=2 "Always show statusline (deafault: only shown when files open > 1)
set statusline=
set statusline+=%7*\[%n]
set statusline+=%#PmenuSel#
set statusline+=\%F
set statusline+=\%{fugitive#statusline()}
set statusline+=%=
set statusline+=%#CursorColumn#
set statusline+=\%y
set statusline+=\%{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\%p%%
set statusline+=\%l:%c
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"6. Plugins "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged/')
Plug 'tpope/vim-fugitive'
Plug 'junegunn/gv.vim'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-commentary'
Plug 'luochen1990/rainbow'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'shime/vim-livedown'
Plug 'easymotion/vim-easymotion'
Plug 'Yggdroot/indentLine'
Plug 'machakann/vim-highlightedyank'
call plug#end()
""" rainbow
let g:rainbow_active = 1
""" GitGutter
"Decrease time between updates (done for GitGutter) (default 4000, i.e. 4 seconds)
set updatetime=1000
"let g:gitgutter_highlight_lines=1
let g:gitgutter_max_signs=9999
""" Livedown
" should markdown preview get shown automatically upon opening markdown buffer
let g:livedown_autorun = 0
" should the browser window pop-up upon previewing
let g:livedown_open = 1
" the port on which Livedown server will run
let g:livedown_port = 1337
" the browser to use
let g:livedown_browser = "firefox"
""" EasyMotion
let g:EasyMotion_do_mapping = 0
map <SPACE>w <Plug>(easymotion-w)
map <SPACE>b <Plug>(easymotion-b)
map <SPACE>s <Plug>(easymotion-s2)
map <SPACE>j <Plug>(easymotion-j)
map <SPACE>k <Plug>(easymotion-k)
""" IndentLine
let g:indentLine_setColors = 0
""" highlightedyank
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
let g:highlightedyank_highlight_duration = 1500
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"7. Functions "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Function to remove trailing whitespaces
function! TrimWhitespace()
let l:save = winsaveview()
%s/\s\+$//e
call winrestview(l:save)
endfunction
command! TrimWhitespace call TrimWhitespace()