-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
executable file
·236 lines (192 loc) · 8.85 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
234
235
236
" -----------------------------------------------------------------
" INSTALLING A COMPATIBLE VIM {{{
" -----------------------------------------------------------------
"
" brew install vim
"
" -----------------------------------------------------------------
" }}} SETUP PLUG {{{
" -----------------------------------------------------------------
" this downloads vim-plug if its missing
if empty(glob("~/.vim/autoload/plug.vim"))
silent! execute '!curl --create-dirs -fLo ~/.vim/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * silent! PlugInstall
endif
" -----------------------------------------------------------------
" }}} GLOBAL BASICS {{{
" -----------------------------------------------------------------
let mapleader = "\<Space>"
let maplocalleader = ','
" this allows scripts in the ~/.vim/ftplugin/ folder to be sourced
" e.g. if you have python specific stuff, make a ~/.vim/ftplugin/python.vim
filetype plugin on
set wrap
" move through wrapped lines
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
noremap <silent> 0 g0
set ai
set history=750
set undolevels=750
set iskeyword+=_,$,@,%,#,-
syntax on
set hlsearch
set number
set list
set mouse=v
nnoremap <Leader>w :w<CR>
nnoremap <Leader>fq :q!<CR>
nnoremap <Leader>q :q<CR>
nnoremap <Leader>e :e
nnoremap :w<CR> <nop>
nnoremap :q<CR> <nop>
nnoremap :e <nop>
nnoremap <Leader>x :xa<CR>
" easily edit and source vimrc (and bash)
nnoremap <leader>ev :split ~/.vimrc<cr>
nnoremap <leader>eb :split ~/.bashrc<cr>
nnoremap <leader>ea :split ~/.bash_aliases<cr>
nnoremap <leader>ep :split ~/.bash_prompt<cr>
nnoremap <leader>sv :source ~/.vimrc<cr>
" moving around splits
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Resize split
nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
" I have set up my clipboards so that when I yank in vim, it places the yanked text into
" my OS clipboard, so that when I cmd+v, it pastes what I yanked. and conversely, when I
" add something to my clipboard with cmd+v, I populate my vim clipboard with it as well
" so when I vim paste it pastes what was in my OS clipboard
set clipboard=unnamed
" Yank filepath of current buffer
nnoremap <c-y> :let @+ = expand('%:p')<cr>
" , is so much easier to type than ` for markers, that I switch them here
nnoremap , `
nnoremap ` '
vnoremap , `
vnoremap ` '
" select what was just pasted
nnoremap gp `[v`]
" select current body
nnoremap ,, {jV}k
" << back-indents in command mode <M back-idents to 0
nnoremap <M ^d0
" related: some times you just want to move a line up (mnemonic: Move Up)
nnoremap MU ^d0i<bs><space><esc>
nnoremap Mu ^d0i<bs><esc>
" when exiting insert mode, the marker f is made
inoremap <esc> <esc>mf
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" When cycling through an autocomplete menu (any autocomplete menu),
" use ctrl j and k to move through, rather than ctrl n and p
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<C-k>"
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smarttab
set expandtab
set backspace=indent,eol,start
set nobackup
set nowritebackup
set noswapfile
map <leader>me :set mouse=v<CR>
map <leader>mm :set mouse=a<CR>
set mouse=a
set noruler
set laststatus=2
" no automatic word wrap, but `gq` wraps to textwidth
set textwidth=88
set fo-=t
" add end and start of line bash equivalents
inoremap <C-e> <C-o>$
inoremap <C-a> <C-o><S-i>
" how far away from max cursor position is from window
set so=1
" show cursorline, causes some amout of lag issues, even with ttyfast and lazyredraw
"set cursorline
set ttyfast
set lazyredraw
" redraw when windowed buffers are entered
nnoremap <leader>rd :redraw!<CR>
autocmd BufWinEnter * execute "redraw!"
" shift-h and shift-l switch buffer in normal mode
nnoremap <s-h> :bp!<CR>
nnoremap <s-l> :bn!<CR>
" close a buffer without second thought
map <leader>c :bw!<CR>
set hidden " unknown what this does
set number relativenumber " hybrid line numbering
"set number " absolute numbering
:highlight LineNr ctermfg=173
" snakemake syntax highlighting
au BufNewFile,BufRead Snakefile set syntax=snakemake
au BufNewFile,BufRead *.smk set syntax=snakemake
" FASTA fasta highlighting
au BufNewFile,BufRead *.fasta,*.fa,*.fna,*.faa setf fasta
onoremap u t_
" operate inside or outside delimiters when cursor is not between
let delimiterList = ['(', ')', '[', ']', '<', '>', '{', '}', '"', "'"]
for delimiter in delimiterList
if delimiter == '"'
execute "onoremap in" . delimiter . " :<C-U>call SmartInner(v:count, 0, '" . delimiter . "', 'i')<CR>"
execute "onoremap an" . delimiter . " :<C-U>call SmartInner(v:count, 0, '" . delimiter . "', 'a')<CR>"
execute "onoremap il" . delimiter . " :<C-U>call SmartInner(v:count, 1, '" . delimiter . "', 'i')<CR>"
execute "onoremap al" . delimiter . " :<C-U>call SmartInner(v:count, 1, '" . delimiter . "', 'a')<CR>"
execute "nnoremap vin" . delimiter . " :<C-U>call SmartInner(v:count, 0, '" . delimiter . "', 'i')<CR>"
execute "nnoremap van" . delimiter . " :<C-U>call SmartInner(v:count, 0, '" . delimiter . "', 'a')<CR>"
execute "nnoremap vil" . delimiter . " :<C-U>call SmartInner(v:count, 1, '" . delimiter . "', 'i')<CR>"
execute "nnoremap val" . delimiter . " :<C-U>call SmartInner(v:count, 1, '" . delimiter . "', 'a')<CR>"
execute "onoremap ji" . delimiter . " :<C-U>call MultiLineInner(v:count, 0, '" . delimiter . "', 'i')<CR>"
execute "onoremap ki" . delimiter . " :<C-U>call MultiLineInner(v:count, 1, '" . delimiter . "', 'i')<CR>"
execute "onoremap ja" . delimiter . " :<C-U>call MultiLineInner(v:count, 0, '" . delimiter . "', 'a')<CR>"
execute "onoremap ka" . delimiter . " :<C-U>call MultiLineInner(v:count, 1, '" . delimiter . "', 'a')<CR>"
execute "nnoremap vji" . delimiter . " :<C-U>call MultiLineInner(v:count, 0, '" . delimiter . "', 'i')<CR>"
execute "nnoremap vki" . delimiter . " :<C-U>call MultiLineInner(v:count, 1, '" . delimiter . "', 'i')<CR>"
execute "nnoremap vja" . delimiter . " :<C-U>call MultiLineInner(v:count, 0, '" . delimiter . "', 'a')<CR>"
execute "nnoremap vka" . delimiter . " :<C-U>call MultiLineInner(v:count, 1, '" . delimiter . "', 'a')<CR>"
else
execute 'onoremap in' . delimiter . ' :<C-U>call SmartInner(v:count, 0, "' . delimiter . '", "i")<CR>'
execute 'onoremap an' . delimiter . ' :<C-U>call SmartInner(v:count, 0, "' . delimiter . '", "a")<CR>'
execute 'onoremap il' . delimiter . ' :<C-U>call SmartInner(v:count, 1, "' . delimiter . '", "i")<CR>'
execute 'onoremap al' . delimiter . ' :<C-U>call SmartInner(v:count, 1, "' . delimiter . '", "a")<CR>'
execute 'nnoremap vin' . delimiter . ' :<C-U>call SmartInner(v:count, 0, "' . delimiter . '", "i")<CR>'
execute 'nnoremap van' . delimiter . ' :<C-U>call SmartInner(v:count, 0, "' . delimiter . '", "a")<CR>'
execute 'nnoremap vil' . delimiter . ' :<C-U>call SmartInner(v:count, 1, "' . delimiter . '", "i")<CR>'
execute 'nnoremap val' . delimiter . ' :<C-U>call SmartInner(v:count, 1, "' . delimiter . '", "a")<CR>'
execute "onoremap ji" . delimiter . ' :<C-U>call MultiLineInner(v:count, 0, "' . delimiter . '", "i")<CR>'
execute "onoremap ki" . delimiter . ' :<C-U>call MultiLineInner(v:count, 1, "' . delimiter . '", "i")<CR>'
execute "onoremap ja" . delimiter . ' :<C-U>call MultiLineInner(v:count, 0, "' . delimiter . '", "a")<CR>'
execute "onoremap ka" . delimiter . ' :<C-U>call MultiLineInner(v:count, 1, "' . delimiter . '", "a")<CR>'
execute "nnoremap vji" . delimiter . ' :<C-U>call MultiLineInner(v:count, 0, "' . delimiter . '", "i")<CR>'
execute "nnoremap vki" . delimiter . ' :<C-U>call MultiLineInner(v:count, 1, "' . delimiter . '", "i")<CR>'
execute "nnoremap vja" . delimiter . ' :<C-U>call MultiLineInner(v:count, 0, "' . delimiter . '", "a")<CR>'
execute "nnoremap vka" . delimiter . ' :<C-U>call MultiLineInner(v:count, 1, "' . delimiter . '", "a")<CR>'
endif
endfor
" Terminal mode
tnoremap kj <C-w>N
" -----------------------------------------------------------------
" CHOOSE YOUR CHARACTER {{{
" -----------------------------------------------------------------
if filereadable(expand("~/.vimrc_abc"))
so ~/.vimrc_abc
elseif filereadable(expand("~/.vimrc_some_other_config"))
so ~/.vimrc_some_other_config
else
so ~/.vimrc_default
endif
" -----------------------------------------------------------------
" }}}
" -----------------------------------------------------------------