-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_vimrc
More file actions
343 lines (256 loc) · 9.53 KB
/
_vimrc
File metadata and controls
343 lines (256 loc) · 9.53 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
runtime! archlinux.vim
execute pathogen#infect()
" --- SETTINGS -------------------------------------------------------------- "
" set mouse=a " Enable Mouse 'a'=for all modes
set incsearch " Incremental Search
set hlsearch " Highlight when searching
set nocompatible " Arrow move Compatible
set background=dark " Background
set history=700 " History length
set number " Show line Numbers
set expandtab " Auto expand tabs to space
set autoindent " Auto indent after a {
set smartindent " Auto indent General
set textwidth=0 " Linewidth to endless
set nowrap " Do not wrap lines automatically
set backspace=start,eol " Repair wired terminal/vim settings
set ignorecase " caseinsensitive searches
set showmode " always show command or insert mode
set ruler " show line and column information
set showmatch " show matching brackets
set formatoptions=tcqor
set whichwrap=b,s,<,>,[,]
set complete+=kspell " Autocomplete when spell check (Ctrl+N / Ctrl+P)
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set splitbelow
set noerrorbells visualbell t_vb=
syntax on " Code Syntax Highlighting
" set ttimeoutlen=0 " Performace Tweaks
" set timeoutlen=1000
set ttyfast
au InsertEnter * set timeout
au InsertLeave * set notimeout
" create persistance state files
set undofile
set undodir=/home/sam/.vim-tmp/ " Set undo file
set directory=/home/sam/.vim-tmp/ " Set Swap file location
set backupdir=/home/sam/.vim-tmp/ " Set Backup file dir
" --- FUNCTIONS ------------------------------------------------------------- "
" --- Highlight 80 Char Overflow
" By Default only show if line > 80
highlight ColorColumn ctermbg=magenta
autocmd VimEnter,WinEnter,BufWinEnter * call matchadd('ColorColumn', '\%81v', 100)
" --- Toggle Line allways show
let s:activatedh = 0
function! Highlight_char80()
if s:activatedh == 0
let s:activatedh = 1
set colorcolumn=81
else
let s:activatedh = 0
set colorcolumn=0
endif
endfunction
" --- Open in Current tab if empty, else newtab
function! OpenNew(fileName)
if bufname("%") == ""
" Current is empty - Open here
:execute ":e" fnameescape(a:fileName)
":e a:fileName <CR>
else
" Not empty - new tab
:execute ":tabnew" fnameescape(a:fileName)
":tabnew a:fileName <CR>
endif
endfunction
" --- Toggle Between modes for line numbers
function! NumberToggle()
if(&relativenumber == 1)
set relativenumber!
else
set relativenumber
endif
endfunc
function! ToggleMouse()
" check if mouse is enabled
if &mouse == 'nv'
" disable mouse
set mouse=
else
" enable mouse everywhere
set mouse=n
endif
endfunc
"" write functions to
" http://vim.wikia.com/wiki/Remove_unwanted_spaces
" remove leading whitespace
" :%s/^\s\+
" remove trailing whitespace
" :%s/\s\+$
" --- QUICK ACCESS ---------------------------------------------------------- "
nnoremap <leader>v :call OpenNew("~/.vimrc")<CR>
nnoremap <leader>b :call OpenNew("~/.bashrc")<CR>
nnoremap <leader>a :call OpenNew("~/.bash_aliases")<CR>
nnoremap <leader>i :call OpenNew("~/.i3/config")<CR>
" --- TEXT FORMATTING MAP --------------------------------------------------- "
"JSON
nmap =j :%!jq .<CR>
"CSV
nmap =c :%!column -t -s ','<CR>
"BIN->HEX
nmap =h :%!xxd<CR><ESC>
"HEX->BIN
nmap =b :%!xxd -r<CR><ESC>
"Lazy set python db trace
nmap =t oimport ipdb; ipdb.set_trace()<ESC>
"Exec current buffer in shell
:command Exec :silent :w !bash
nmap =e :Exec<CR><ESC>
"Line insert
nmap =l o# ---------------------------------------------------------------------------<ESC>
" --- KEY BINDINGS ---------------------------------------------------------- "
" Prevent Accidental Encryption / skip save
map! X<CR> x<CR>
map! W<CR> w<CR>
map W<CR> w<CR>
" Force sudo write using ':w!!'
cmap w!! w !sudo tee > /dev/null %
" Quick buffer next / prev
nnoremap <C-[> :bp<CR>
nnoremap <C-]> :bn<CR>
" Remap Freeze flow control to save file
:nmap <c-s> :w<CR>
:imap <c-s> <Esc>:w<CR>a
" Search for visually selected text
" note that '*' will work for word under cursor [vim default]
vnoremap // y/<C-R>"<CR>
" Non-Escape key exit from insert mode
imap <C-c> <Esc>l
" Move from Insert -> visual block Mode
imap <c-v> <esc><C-v>
" Disable Replace mode by <Insert>, use (Shift-R)
nnoremap <Insert> i
inoremap <Insert> <Esc>l
" Prevent Accidental Encryption / skip save
map! X<CR> x<CR>
map! W<CR> w<CR>
map W<CR> w<CR>
" Paragraph Move Ctrl+Up, normal,visual, select
" Paragraph Move Ctrl+Up, insert
" Paragraph Move Ctrl+Dwn, normal,visual, select
" Paragraph Move Ctrl+Dwn, insert
map <ESC>Ob })
map <ESC>Oa {(
map! <ESC>Oa {(
map! <ESC>Ob })
" Ctrl+a Move Line start
map <C-alt-a> <ESC> <home>
map <C-o> <ESC>
" Ctrl+e move line end
map <C-e> <ESC> <end>
" Fix paste from visual mode
vmap <C-S-v> <ESC>a "+p
" Refresh vimrc without exit
nnoremap <leader>r :so $MYVIMRC<CR>
" save and close all
nnoremap <leader>c :qa<CR>
" tabnew shortcut
nnoremap <leader>d :tabnew<CR>
cabbrev E Explore
" Ctrl+h/ Ctrl+l ti move between tabs
nnoremap <C-l> gt
nnoremap <C-h> gT
" Spell Check Prev/Next wrong word
" nnoremap <C-z> [sz=0`]
" nnoremap <C-x> ]sz=0`]
" --- TOGGLES --------------------------------------------------------------- "
" F1 File Browser
noremap <F1> :NERDTreeToggle<CR>
inoremap <F1> :NERDTreeToggle<CR>
" F2 Paste mode for line indents
set pastetoggle=<F2>
" F3 Paste mode for line indents
nnoremap <F3> :call NumberToggle()<cr>
" F4 Line numbers
noremap <F4> :set invnumber <CR>:GitGutterToggle <CR>
inoremap <F4> <C-O>:set invnumber<CR>:GitGutterToggle <CR>
" F5 QUICK SAVE
" nnoremap <F5> :call ToggleMouse()<CR>
" F6` Toggle 80 Char indicator
nnoremap <F6> :call Highlight_char80()<CR>
" F7 Text wrap
nnoremap <F7> :set wrap! wrap?<CR>
imap <F7> <C-O><F7>
" F8 Search Highlight
noremap <F8> :set hlsearch! hlsearch?<CR>
imap <F8> <C-O><F8>
" F9 Remove Trailing Whitespace
nnoremap <F9> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" F10 Spell Checker (Use: [s, ]s, z=)
nnoremap <F10> :setlocal spell! spelllang=en<CR>
" nnoremap <F10> :setlocal spell! spelllang=en_gb <CR>
imap <F10> <C-O><F10>
" F11 Run Bash
nnoremap <F11> :terminal ipython<CR>
" F12 Run Bash
nnoremap <F12> :terminal bash<CR>
"" File Browser - Ctrl-X
" map <silent> <C-X> :NERDTreeToggle<CR>
" imap <C-X> <esc> :NERDTreeToggle<CR>
" --- COLOUR SCHEME --------------------------------------------------------- "
" Set Line Number Background as black
highlight LineNr ctermbg=234
" Set Vertical split Line as Solid Black
hi VertSplit term=NONE cterm=bold ctermfg=16 ctermbg=16
" Set Empty buffer as gray
highlight NonText ctermbg=239
" Set Cursor Line Colour Scheme
hi CursorLine cterm=NONE
hi CursorLineNR ctermbg=red
"hi CursorLineNR ctermbg=88
" Only Show Cursor line in Active Buffer
augroup CLNRSet
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" VIM spell checker to underline
hi clear SpellBad
hi SpellBad cterm=underline,bold ctermfg=red
" --- PLUGIN CONFIG --------------------------------------------------------- "
" Latex-Box
" filetype plugin on
" set grepprg=grep\ -nH\ $*
" filetype indent on
" let g:tex_flavor='latex'
" let g:Tex_DefaultTargetFormat = 'pdf'
" let g:Tex_CompileRule_pdf = 'latexmk -pdf -f $*'
" set iskeyword+=:
" Fuzzy search - (https://github.com/ctrlpvim/ctrlp.vim)
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_show_hidden = 1
" Vim-airline - (http://vimawesome.com/plugin/vim-airline)
let g:airline_theme='distinguished' " Select Theme from ~/.vim/bundle/vim-airline-themes/autoload/airline/themes
set t_Co=256 " Enable Colours
set laststatus=2 " Show airline bar for single files
set noshowmode " Hide --INSERT-- from bottom status bar
" Append Current User to Status Bar
call airline#parts#define_raw('user', '%{$USER} ')
let g:airline_section_y = airline#section#create_right([ 'user' , 'ffenc'])
" Enable vim-airline bufferbar replacment
let g:airline#extensions#tabline#enabled = 1
" Setup Symbols
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:Powerline_symbols = 'fancy'
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '↝'
let g:airline_symbols.paste = 'PASTE'