aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-04-14 13:06:17 +0200
committerCharles <sircharlesaze@gmail.com>2020-04-14 13:06:17 +0200
commit5828534933ffd5ca23c6e47b7c12a4a2637e01f0 (patch)
tree4385c66fabdaf2dd71a8f7cc2fabca49fb2896dd /.vimrc
parent10d80f8d2858de6da4a73073e3f68dfd269d6cff (diff)
downloaddotfiles-5828534933ffd5ca23c6e47b7c12a4a2637e01f0.tar.gz
dotfiles-5828534933ffd5ca23c6e47b7c12a4a2637e01f0.tar.bz2
dotfiles-5828534933ffd5ca23c6e47b7c12a4a2637e01f0.zip
Added vim functions to help with boilerplate in c++ files
Diffstat (limited to '.vimrc')
-rw-r--r--.vimrc59
1 files changed, 54 insertions, 5 deletions
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 <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>
+" nnoremap <C-S-J> <C-W><S-J>
+" nnoremap <C-S-K> <C-W><S-K>
+" nnoremap <C-S-L> <C-W><S-L>
+" nnoremap <C-S-H> <C-W><S-H>
nnoremap <leader>s= <C-W>=
" }}}
@@ -129,7 +144,29 @@ nnoremap <leader>src :source $MYVIMRC<cr>
" c {{{
" create c function body from prototype
-nnoremap gcf A<BS><CR>{<CR><CR>}<ESC>
+nnoremap gcf A<BS><CR>{<CR><CR>}<CR><ESC>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<CR>:call PutHeaderBoilerPlate()<CR>
+
+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 <leader>; mqA;<ESC>`q
" doxygen format comments
@@ -138,7 +175,9 @@ autocmd Filetype cpp setlocal comments=s:/**,m:**,e:*/,s:/*,m:**,e:*/
" }}}
" quickfix window toggle {{{
-nnoremap <leader>q :call QuickfixToggle()<CR>
+nnoremap <leader>qt :call QuickfixToggle()<CR>
+nnoremap <leader>qn :cnext <CR>
+nnoremap <leader>qp :cprevious <CR>
let g:quickfix_is_open = 0
if !exists('*QuickfixToggle')
function QuickfixToggle()
@@ -153,11 +192,13 @@ if !exists('*QuickfixToggle')
endif
" }}}
+" make {{{
+nnoremap <leader>m :make all <CR>
+" }}}
+
" 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 <buffer> q: hmmmm??
+" }}}