From 5828534933ffd5ca23c6e47b7c12a4a2637e01f0 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 14 Apr 2020 13:06:17 +0200 Subject: Added vim functions to help with boilerplate in c++ files --- .vimrc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to '.vimrc') diff --git a/.vimrc b/.vimrc index 1fc69f0..a8d3bf4 100644 --- a/.vimrc +++ b/.vimrc @@ -20,11 +20,13 @@ set numberwidth=1 " line numbers gutter autowidth set cursorline " highlight current line set noshowmatch " dont jump to pair bracket set autoread " reload files when changes happen outside vim +set autowrite " auto write buf on certain events set hidden " keep change in buffer when quitting window set noswapfile " disable swap files set scrolloff=2 " line padding when scrolling set textwidth=89 " when line wrap occurs set encoding=utf-8 " utf-8 encoding +set formatoptions-=t " do not auto break line > 89 character filetype plugin indent on " allow to add specific rules for certain type of file " }}} @@ -37,7 +39,7 @@ set path+=** " recursive :find " intuitif split opening {{{ set splitbelow set splitright -set fcs+=vert:\ " no split separator +set fcs+=vert:│ " split separator " }}} " tab {{{ @@ -64,6 +66,7 @@ set noshowmode " dont show current mode (i.e --INSERT--) " fold {{{ set foldmethod=indent " create fold based on the text indent +set nofoldenable " not folded by default " }}} """"""""""""""" @@ -73,6 +76,14 @@ set foldmethod=indent " create fold based on the text indent " one {{{ let g:onedark_terminal_italics=1 colorscheme onedark +" }}} +" dracula {{{ +let g:dracula_bold = 1 +let g:dracula_italic = 1 +let g:dracula_colorterm = 0 +" colorscheme dracula +" }}} +" lightline {{{ let g:lightline = {} let g:lightline.colorscheme = 'jellybeans' " lightline theme to onedark " }}} @@ -87,6 +98,10 @@ nnoremap nnoremap nnoremap nnoremap +" nnoremap +" nnoremap +" nnoremap +" nnoremap nnoremap s= = " }}} @@ -129,7 +144,29 @@ nnoremap src :source $MYVIMRC " c {{{ " create c function body from prototype -nnoremap gcf A{} +nnoremap gcf A{}j + +" initialise a school header file +function PutHeaderBoilerPlate() + let l:filename = join(split(toupper(expand('%:t')), '\.'), "_") + " echom l:filename + call append(12, "#ifndef " . l:filename) + call append(13, "# define " . l:filename) + call append(15, "#endif") +endfunction +nnoremap gch :Stdheader:call PutHeaderBoilerPlate() + +function PutCoplienForm(name) + let l:default_constructor = a:name . "();\n" + let l:copy_constructor = a:name . "(" . a:name . " const& other);\n" + let l:copy_operator = "void operator=(" . a:name . " const& other);\n" + let l:destructor = "~" . a:name . "();\n" + + execute "normal iclass " . a:name . "\n{\npublic:\n" . l:default_constructor . l:copy_constructor . l:copy_operator . l:destructor . "\nprivate:\n};\n" + execute "normal <2{" +endfunction +command! PutCoplienFormFile call PutCoplienForm(split(expand('%:t'), '\.')[0]) + " put semicolon at the end of line nnoremap ; mqA;`q " doxygen format comments @@ -138,7 +175,9 @@ autocmd Filetype cpp setlocal comments=s:/**,m:**,e:*/,s:/*,m:**,e:*/ " }}} " quickfix window toggle {{{ -nnoremap q :call QuickfixToggle() +nnoremap qt :call QuickfixToggle() +nnoremap qn :cnext +nnoremap qp :cprevious let g:quickfix_is_open = 0 if !exists('*QuickfixToggle') function QuickfixToggle() @@ -153,11 +192,13 @@ if !exists('*QuickfixToggle') endif " }}} +" make {{{ +nnoremap m :make all +" }}} + " hook {{{ " remove trailing white space on save autocmd BufWritePre * %s/\s\+$//e -" initialise buf for fold toggle -autocmd BufReadPre * :normal zMzi " }}} " filetype {{{ @@ -177,8 +218,16 @@ autocmd Filetype vim setlocal foldmethod=marker set wildignore=*/tmp/*,*.o,*.so,*.swp,*.zip,*/node_modules/*,*/vendor/*,.bundle/*,bin/*,.git/* " ctrlp ignore all stuff in the .gitignore let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] +let g:ctrlp_working_path_mode = 'rw' " }}} " quick-scope {{{ let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] " }}} + +" man-plugin {{{ +runtime! ftplugin/man.vim +let g:ft_man_open_mode = 'vert' " open in a vertical split +let g:ft_man_no_sect_fallback = 2 " if page specified fallback to page 2 (syscall pages) +" autocmd Filetype man unmap q: hmmmm?? +" }}} -- cgit