dotfiles

Configuration dotfiles
git clone git://git.wimdupont.com/dotfiles.git
Log | Files | Refs | README | LICENSE

vimrc (4608B)


      1 " All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just
      2 " /usr/share/vim/vimfiles/archlinux.vim) and sourced by the call to :runtime
      3 " you can find below.  If you wish to change any of those settings, you should
      4 " do it in this file (/etc/vimrc), since archlinux.vim will be overwritten
      5 " everytime an upgrade of the vim packages is performed.  It is recommended to
      6 " make changes after sourcing archlinux.vim since it alters the value of the
      7 " 'compatible' option.
      8 
      9 " This line should not be removed as it ensures that various options are
     10 " properly set to work with the Vim-related packages.
     11 runtime! archlinux.vim
     12 
     13 " If you prefer the old-style vim functionalty, add 'runtime! vimrc_example.vim'
     14 " Or better yet, read /usr/share/vim/vim80/vimrc_example.vim or the vim manual
     15 " and configure vim to your own liking!
     16 
     17 " do not load defaults if ~/.vimrc is missing
     18 "let skip_defaults_vim=1
     19 
     20 "set spell
     21 set tw=0
     22 set wrapmargin=1
     23 set nu relativenumber
     24 set hlsearch
     25 set ic
     26 
     27 let t:is_transparent = 1
     28 let t:is_book = 0
     29 let g:netrw_winsize = 20
     30 
     31 function! Toggle_transparent()
     32 	:colors default
     33 	call Set_Highlights()
     34 	if t:is_transparent == 0
     35 		hi Normal guibg=NONE ctermbg=NONE
     36 		let t:is_transparent = 1
     37 	else
     38 		hi Normal guibg=#111111 ctermbg=black
     39 		let t:is_transparent = 0
     40 	endif
     41 endfunction
     42 
     43 function! Set_Highlights()
     44 	highlight VertSplit		cterm=none	gui=none
     45 	highlight StatusLineNC		ctermbg=241	ctermfg=0
     46 	highlight StatusLine		ctermbg=0	ctermfg=238
     47 	highlight IncSearch		ctermbg=3	ctermfg=1
     48 	highlight Search		ctermbg=241	ctermfg=3
     49 	highlight StatusLineTerm	ctermbg=238	ctermfg=0	cterm=NONE
     50 	highlight StatusLineTermNC	ctermbg=0	ctermfg=238	cterm=NONE
     51 endfunction
     52 
     53 function! Toggle_bookmode()
     54 	if t:is_book == 0
     55 		set tw=80
     56 		set wrapmargin=0
     57 		call Format()
     58 		let t:is_book = 1
     59 	else
     60 		set tw=0
     61 		set wrapmargin=1
     62 		call Format()
     63 		let t:is_book = 0
     64 	endif
     65 endfunction
     66 
     67 function! Change_Res(op,val,isvert)
     68 	let c = v:count == 0 ? 1*a:val : v:count*a:val
     69 	let cmd = a:isvert ? ':vert res' : ':res'
     70 	exec cmd . a:op . c
     71 	echo a:op . c
     72 endfunction
     73 
     74 function! Set_IDE()
     75 	:Lex
     76 	:bo term
     77 	:resize -10
     78 	wincmd w
     79 	wincmd w
     80 endfunction
     81 
     82 function! Format()
     83 	call feedkeys("gggqG")
     84 	call Clear_whitespace()
     85 endfunction
     86 
     87 function! Clear_whitespace()
     88 	:%s/\ *\ /\ /g
     89 endfunction
     90 
     91 runtime! ftplugin/man.vim
     92 
     93 tnoremap <leader>w <C-w><C-w>
     94 tnoremap <leader>i <C-w><S-n>
     95 tnoremap <leader>R <C-w><S-n>:so /etc/vimrc<CR>i
     96 tnoremap <leader>t <C-w><S-n>: call Toggle_transparent()<CR>i
     97 tnoremap <leader><up> <C-w><S-n>:<C-U>call Change_Res('+',5,0)<CR>i
     98 tnoremap <leader><down> <C-w><S-n>:<C-U>call Change_Res('-',5,0)<CR>i
     99 tnoremap <leader><right> <C-w><S-n>:<C-U>call Change_Res('+',5,1)<CR>i
    100 tnoremap <leader><left> <C-w><S-n>:<C-U>call Change_Res('-',5,1)<CR>i
    101 
    102 nnoremap <leader><up> :<C-U>call Change_Res('+',5,0)<CR>
    103 nnoremap <leader><down> :<C-U>call Change_Res('-',5,0)<CR>
    104 nnoremap <leader><right> :<C-U>call Change_Res('+',5,1)<CR>
    105 nnoremap <leader><left> :<C-U>call Change_Res('-',5,1)<CR>
    106 nnoremap <leader>w <C-w><C-w>
    107 nnoremap <leader>R :so /etc/vimrc<CR>
    108 nnoremap <leader>T :bo ter<CR>
    109 nnoremap <leader>t : call Toggle_transparent()<CR>
    110 nnoremap <leader>b : call Toggle_bookmode()<CR>
    111 nnoremap <leader>f : call Format()<CR>
    112 nnoremap <leader>c : call Clear_whitespace()<CR>
    113 nnoremap <leader>e : call Set_IDE()<CR>
    114 
    115 vnoremap <leader>y "+y
    116 vnoremap <leader>p "+p
    117 vnoremap <leader>P "_dP
    118 
    119 cmap suw w !sudo tee > /dev/null %
    120 
    121 autocmd BufWritePost,FileWritePost config.def.h !sudo rm config.h && sudo make install
    122 autocmd VimEnter * call Set_Highlights()
    123 
    124 autocmd FileType asciidoc map <F2> :w <CR> :!htmlconv %<CR>
    125 autocmd FileType markdown map <F2> :w <CR> :!htmlconv %<CR>
    126 autocmd FileType c map <F2> :w <CR> :!gcc % -o %< && ./%< <CR>
    127 autocmd FileType c map <F3> :w <CR> :!gcc % -g -o %< && gdb ./%< <CR>
    128 autocmd FileType cpp map <F2> :w <CR> :!g++ % -o %< && ./%< <CR>
    129 autocmd FileType cpp map <F3> :w <CR> :!g++ % -g -o %< && gdb ./%< <CR>
    130 autocmd FileType c,cpp map <F4> :w <CR> :!make && ./%< <CR>
    131 autocmd FileType c,cpp map <F5> :w <CR> :!make && gdb ./%< <CR>
    132 
    133 autocmd FileType c :command! -bar -nargs=* Run :w | :!gcc % -o %< && ./%< <args>
    134 autocmd FileType c :command! -bar -nargs=* Rund :w | :!gcc % -o %< && gdb --args ./%< <args>
    135 autocmd FileType cpp :command! -bar -nargs=* Run :w | :!g++ % -o %< && ./%< <args>
    136 autocmd FileType cpp :command! -bar -nargs=* Rund :w | :!g++ % -o %< && gdb --args ./%< <args>
    137 autocmd FileType c,cpp :command! -bar -nargs=* Runm :w | :!make && ./%< <args>
    138 autocmd FileType c,cpp :command! -bar -nargs=* Runmd :w | :!make && gdb --args ./%< <args>