From eb3953dc172fbe1f6a9f23f1a14922384bf1492f Mon Sep 17 00:00:00 2001 From: Bradley Small <vc.Bradley.Small@lowes.com> Date: Wed, 13 Nov 2019 14:18:29 -0500 Subject: [PATCH] reorganizing vimrc --- .vim/ftplugin/html.vim | 5 + .vimrc | 483 +++++++++++++++++++++-------------------- 2 files changed, 250 insertions(+), 238 deletions(-) diff --git a/.vim/ftplugin/html.vim b/.vim/ftplugin/html.vim index e69de29..7c20267 100644 --- a/.vim/ftplugin/html.vim +++ b/.vim/ftplugin/html.vim @@ -0,0 +1,5 @@ + +let g:html_indent_style1 = "inc" +let g:html_indent_script1 = "inc" +let g:html_indent_inctags = "style" + diff --git a/.vimrc b/.vimrc index 6b9a152..a43af2f 100644 --- a/.vimrc +++ b/.vimrc @@ -1,6 +1,5 @@ " ~/.vimrc (configuration file for vim only){{{ -" Configuration settings ------------------{{{}}} -" allow backspacing over everything in insert mode +" " Plugged Plugins -------------------------{{{ call plug#begin('~/.vim/plugged') " @@ -22,29 +21,103 @@ Plug 'vimwiki/vimwiki' call plug#end() " }}} +" Configuration settings ------------------{{{ +" +" allow backspacing over everything in insert mode +set autoindent " always set autoindenting on +set autowrite set backspace=indent,eol,start - -set backup " keep a backup file -set history=50 " keep 50 lines of command line history -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set incsearch " do incremental searching -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 +set cindent set expandtab +set guifont=DejaVu\ Sans\ Mono\ 12 +set history=50 " keep 50 lines of command line history +set hlsearch +set incsearch " do incremental searching set number -set autowrite -set autoindent " always set autoindenting on +set ruler " show the cursor position all the time +set shiftwidth=4 +set showcmd " display incomplete commands set smartindent -set cindent -set wrap! +set softtabstop=4 +set tabstop=4 set termguicolors -syntax on -colorscheme koehler -" filetypes -------------------------------{{{ +set wrap! +" set list listchars=tab:»»,trail:•,precedes:â†,extends:→,space:·,eol:¶ +set list listchars=tab:»»,trail:•,precedes:â†,extends:→,space:\ ,eol:¶ +set clipboard=unnamedplus,unnamed + filetype plugin on filetype indent on + +syntax on +syntax enable + +colorscheme koehler +" }}} + +" swap file stuff --------------------------------------------------{{{ +" Save your backups to a less annoying place than the current directory. +" If you have .vim-backup in the current directory, it'll use that. +" Otherwise it saves it to ~/.vim/backup or . if all else fails. +if isdirectory($HOME . '/.vim/backup') == 0 + :silent !mkdir -p ~/.vim/backup >/dev/null 2>&1 +endif +set backupdir-=. +set backupdir+=. +set backupdir-=~/ +set backupdir^=~/.vim/backup/ +set backupdir^=./.vim-backup/ +set backup + +" Save your swp files to a less annoying place than the current directory. +" If you have .vim-swap in the current directory, it'll use that. +" Otherwise it saves it to ~/.vim/swap, ~/tmp or . +if isdirectory($HOME . '/.vim/swap') == 0 + :silent !mkdir -p ~/.vim/swap >/dev/null 2>&1 +endif +set directory=./.vim-swap// +set directory+=~/.vim/swap// +set directory+=~/tmp// +set directory+=. + +" viminfo stores the the state of your previous editing session +set viminfo+=n~/.vim/viminfo + +if exists("+undofile") + " undofile - This allows you to use undos after exiting and restarting + " This, like swap and backups, uses .vim-undo first, then ~/.vim/undo + " :help undo-persistence + " This is only present in 7.3+ + if isdirectory($HOME . '/.vim/undo') == 0 + :silent !mkdir -p ~/.vim/undo > /dev/null 2>&1 + endif + set undodir=./.vim-undo// + set undodir+=~/.vim/undo// + set undofile +endif +"}}} + +" Extra Terminal Stuff ----------------------------- {{{ +" In many terminal emulators the mouse works just fine, thus enable it. +if has('mouse') + set mouse=a +endif + +" Switch syntax highlighting on, when the terminal has colors +" Also switch on highlighting the last used search pattern. +if &t_Co > 2 || has("gui_running") + syntax on + set hlsearch +endif + +"if has('gui_running') +" set background=light +"else +" let g:solarized_termcolors=16 +" set background=light +"endif +"set background=dark +"colorscheme solarized " }}} " Leader settings ------------------------{{{ @@ -52,105 +125,26 @@ let mapleader = "\\" let maplocalleader = "\\" " }}} -let g:netrw_banner = 0 -let g:netrw_liststyle = 3 -let g:netrw_browse_split = 4 -let g:netrw_altv = 1 -let g:netrw_winsize = 15 -" augroup ProjectDrawer -" autocmd! -" autocmd VimEnter * :Vexplore -" augroup END - -autocmd FileType netrw setl bufhidden=delete -nnoremap <F2> :Vexplore<CR> - -let g:html_indent_style1 = "inc" -let g:html_indent_script1 = "inc" -let g:html_indent_inctags = "style" - -"bms if has ( "win32unix" ) -"bms set shell=/bin/bash -"bms set shellcmdflag=--login\ -c -"bms elseif has ( "unix" ) -"bms set shell=/bin/bash -"bms set shellcmdflag=--login\ -c -"bms set path=.,,/usr/include,./inc,../inc,./include,../include,~/include,inc,include -"bms else -"bms set shell=cmd.exe -"bms endif - "#set shellxquote=\" +" Q setting ------------------------------------ {{{ " Don't use Ex mode, use Q for formatting map Q gq " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. inoremap <C-U> <C-G>u<C-U> - -set guifont=DejaVu\ Sans\ Mono\ 12 - -" start with file modification status -set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P -" set statusline=%m -" " then file name/path -" set statusline+=%f -" " some separation and the file type -" set statusline+=\ -\ FileType:\ %y -" " switch to the right side -" set statusline+=%= -" " put the current line -" set statusline+=%l -" " put the column and virtual colum prefaced by a comma -" set statusline+=,%c%V -" " followed by a slash and the total lines in the file -" set statusline+=/%L -" }}} - -" skeletons -------------------------------------------{{{ -function! SKEL_spec() - 0r /usr/share/vim/current/skeletons/skeleton.spec - language time en_US - if $USER != '' - let login = $USER - elseif $LOGNAME != '' - let login = $LOGNAME - else - let login = 'unknown' - endif - let newline = stridx(login, "\n") - if newline != -1 - let login = strpart(login, 0, newline) - endif - if $HOSTNAME != '' - let hostname = $HOSTNAME - else - let hostname = system('hostname -f') - if v:shell_error - let hostname = 'localhost' - endif - endif - let newline = stridx(hostname, "\n") - if newline != -1 - let hostname = strpart(hostname, 0, newline) - endif - exe "%s/specRPM_CREATION_DATE/" . strftime("%a\ %b\ %d\ %Y") . "/ge" - exe "%s/specRPM_CREATION_AUTHOR_MAIL/" . login . "@" . hostname . "/ge" - exe "%s/specRPM_CREATION_NAME/" . expand("%:t:r") . "/ge" - setf spec -endfunction " }}} -" Convenience Mappings ----------------------{{{ -" swap lines down -nnoremap <leader>- ddpk -" swap lines up -nnoremap <leader>_ ddkPj - +" commands to endit vim settings ------ {{{ " edit the _vimrc file in a split nnoremap <leader>ev :split $MYVIMRC<cr> +" edit the _ftplugin/python.vim fileMYVIMRC in a split +nnoremap <leader>ep :split $HOME/.vim/ftplugin/python.vim<cr> " reread (source) the current _vimrc nnoremap <leader>sv :source $MYVIMRC<cr> "change directory to that of current file +" }}} + +" change to the current working dir of the file ------{{{ nnoremap <leader>cd :cd %:p:h<CR> " }}} @@ -180,13 +174,94 @@ onoremap il{ :<c-u>normal! F}vi{<cr> onoremap in@ :<c-u>execute "normal! :nohlsearch\r/[a-zA-Z0-9_.]\\+@[a-zA-Z0-9_.]\\+\r:nohlsearch\rv/[^a-zA-Z0-9_.@]\r"<cr> " }}} +" Status line --------------{{{ +" start with file modification status +set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P +" set statusline=%m +" " then file name/path +" set statusline+=%f +" " some separation and the file type +" set statusline+=\ -\ FileType:\ %y +" " switch to the right side +" set statusline+=%= +" " put the current line +" set statusline+=%l +" " put the column and virtual colum prefaced by a comma +" set statusline+=,%c%V +" " followed by a slash and the total lines in the file +" set statusline+=/%L +" }}} + +" netrw settings -------------------------{{{ +let g:netrw_banner = 0 +let g:netrw_liststyle = 3 +let g:netrw_browse_split = 4 +let g:netrw_altv = 1 +let g:netrw_winsize = 15 +" augroup ProjectDrawer +" autocmd! +" autocmd VimEnter * :Vexplore +" augroup END + +autocmd FileType netrw setl bufhidden=delete +nnoremap <F2> :Vexplore<CR> +" }}} + +" shell settings =========================={{{ +"bms if has ( "win32unix" ) +"bms set shell=/bin/bash +"bms set shellcmdflag=--login\ -c +"bms elseif has ( "unix" ) +"bms set shell=/bin/bash +"bms set shellcmdflag=--login\ -c +"bms set path=.,,/usr/include,./inc,../inc,./include,../include,~/include,inc,include +"bms else +"bms set shell=cmd.exe +"bms endif + "#set shellxquote=\" +"}}} + +" skeletons -------------------------------------------{{{ +" function! SKEL_spec() +" 0r /usr/share/vim/current/skeletons/skeleton.spec +" language time en_US +" if $USER != '' +" let login = $USER +" elseif $LOGNAME != '' +" let login = $LOGNAME +" else +" let login = 'unknown' +" endif +" let newline = stridx(login, "\n") +" if newline != -1 +" let login = strpart(login, 0, newline) +" endif +" if $HOSTNAME != '' +" let hostname = $HOSTNAME +" else +" let hostname = system('hostname -f') +" if v:shell_error +" let hostname = 'localhost' +" endif +" endif +" let newline = stridx(hostname, "\n") +" if newline != -1 +" let hostname = strpart(hostname, 0, newline) +" endif +" exe "%s/specRPM_CREATION_DATE/" . strftime("%a\ %b\ %d\ %Y") . "/ge" +" exe "%s/specRPM_CREATION_AUTHOR_MAIL/" . login . "@" . hostname . "/ge" +" exe "%s/specRPM_CREATION_NAME/" . expand("%:t:r") . "/ge" +" setf spec +" endfunction +" }}} + " Vimscript file settings ---------------------------{{{ augroup filetype_vim - autocmd! - autocmd FileType vim nnoremap <buffer> <localleader>c I" - autocmd FileType vim setlocal foldmethod=marker - autocmd FileType vim setlocal nowrap - autocmd FileType vim setlocal foldlevelstart=0 + autocmd! + autocmd FileType vim nnoremap <buffer> <localleader>c I" + autocmd FileType vim setlocal foldmethod=marker + autocmd FileType vim setlocal nowrap + autocmd FileType vim setlocal foldlevelstart=0 augroup END " }}} @@ -199,58 +274,58 @@ augroup END " C file settings ---------------------------------{{{ augroup filetype_c - autocmd! - autocmd Filetype c setlocal textwidth=80 - autocmd Filetype c setlocal colorcolumn=80 - autocmd FileType c nnoremap <buffer> <localleader>c I// - autocmd FileType c vnoremap <buffer> <localleader>c I// - autocmd fileType c nnoremap <buffer> <localleader>/ I/*<esc>A*/<esc>j^ - autocmd fileType c vnoremap <buffer> <localleader>/ <esc>`>a*/<esc>`<i/*<esc> - autocmd fileType c nnoremap <buffer> <localleader>" viw<esc>a"<esc>hbi"<esc>lel - autocmd fileType c nnoremap <buffer> <localleader>' viw<esc>a'<esc>hbi'<esc>lel - autocmd fileType c vnoremap <buffer> <localleader>" <esc>`>a"<esc>`<i"<esc> - autocmd fileType c vnoremap <buffer> <localleader>' <esc>`>a'<esc>`<i'<esc> - autocmd FileType c nnoremap <buffer> [[ ?{<CR>w99[{ - autocmd FileType c nnoremap <buffer> ][ /}<CR>b99]} - autocmd FileType c nnoremap <buffer> ]] j0[[%/{<CR> - autocmd FileType c nnoremap <buffer> [] k$][%?}<CR> - autocmd BufNewFile *.c 0r ~/.vim/skel/c.skel + autocmd! + autocmd Filetype c setlocal textwidth=80 + autocmd Filetype c setlocal colorcolumn=80 + autocmd FileType c nnoremap <buffer> <localleader>c I// + autocmd FileType c vnoremap <buffer> <localleader>c I// + autocmd fileType c nnoremap <buffer> <localleader>/ I/*<esc>A*/<esc>j^ + autocmd fileType c vnoremap <buffer> <localleader>/ <esc>`>a*/<esc>`<i/*<esc> + autocmd fileType c nnoremap <buffer> <localleader>" viw<esc>a"<esc>hbi"<esc>lel + autocmd fileType c nnoremap <buffer> <localleader>' viw<esc>a'<esc>hbi'<esc>lel + autocmd fileType c vnoremap <buffer> <localleader>" <esc>`>a"<esc>`<i"<esc> + autocmd fileType c vnoremap <buffer> <localleader>' <esc>`>a'<esc>`<i'<esc> + autocmd FileType c nnoremap <buffer> [[ ?{<CR>w99[{ + autocmd FileType c nnoremap <buffer> ][ /}<CR>b99]} + autocmd FileType c nnoremap <buffer> ]] j0[[%/{<CR> + autocmd FileType c nnoremap <buffer> [] k$][%?}<CR> + autocmd BufNewFile *.c 0r ~/.vim/skel/c.skel augroup END " }}} " CPP file settings ---------------------------------{{{ augroup filetype_cpp - autocmd! - autocmd Filetype cpp setlocal textwidth=80 - autocmd Filetype cpp setlocal colorcolumn=80 - autocmd FileType cpp nnoremap <buffer> <localleader>c I// - autocmd FileType cpp vnoremap <buffer> <localleader>c I// - autocmd fileType cpp nnoremap <buffer> <localleader>/ I/*<esc>A*/<esc>j^ - autocmd fileType cpp vnoremap <buffer> <localleader>/ <esc>`>a*/<esc>`<i/*<esc> - autocmd fileType cpp nnoremap <buffer> <localleader>" viw<esc>a"<esc>hbi"<esc>lel - autocmd fileType cpp nnoremap <buffer> <localleader>' viw<esc>a'<esc>hbi'<esc>lel - autocmd fileType cpp vnoremap <buffer> <localleader>" <esc>`>a"<esc>`<i"<esc> - autocmd fileType cpp vnoremap <buffer> <localleader>' <esc>`>a'<esc>`<i'<esc> - autocmd FileType cpp nnoremap <buffer> [[ ?{<CR>w99[{ - autocmd FileType cpp nnoremap <buffer> ][ /}<CR>b99]} - autocmd FileType cpp nnoremap <buffer> ]] j0[[%/{<CR> - autocmd FileType cpp nnoremap <buffer> [] k$][%?}<CR> - autocmd BufNewFile *.cpp 0r ~/.vim/skel/cpp.skel + autocmd! + autocmd Filetype cpp setlocal textwidth=80 + autocmd Filetype cpp setlocal colorcolumn=80 + autocmd FileType cpp nnoremap <buffer> <localleader>c I// + autocmd FileType cpp vnoremap <buffer> <localleader>c I// + autocmd fileType cpp nnoremap <buffer> <localleader>/ I/*<esc>A*/<esc>j^ + autocmd fileType cpp vnoremap <buffer> <localleader>/ <esc>`>a*/<esc>`<i/*<esc> + autocmd fileType cpp nnoremap <buffer> <localleader>" viw<esc>a"<esc>hbi"<esc>lel + autocmd fileType cpp nnoremap <buffer> <localleader>' viw<esc>a'<esc>hbi'<esc>lel + autocmd fileType cpp vnoremap <buffer> <localleader>" <esc>`>a"<esc>`<i"<esc> + autocmd fileType cpp vnoremap <buffer> <localleader>' <esc>`>a'<esc>`<i'<esc> + autocmd FileType cpp nnoremap <buffer> [[ ?{<CR>w99[{ + autocmd FileType cpp nnoremap <buffer> ][ /}<CR>b99]} + autocmd FileType cpp nnoremap <buffer> ]] j0[[%/{<CR> + autocmd FileType cpp nnoremap <buffer> [] k$][%?}<CR> + autocmd BufNewFile *.cpp 0r ~/.vim/skel/cpp.skel augroup END " }}} " Javascript file settings ---------------------------{{{ augroup filetype_javascript - autocmd FileType javascript nnoremap <buffer> <localleader>c I// + autocmd FileType javascript nnoremap <buffer> <localleader>c I// augroup END " }}} " Html file settings ---------------------------------{{{ augroup filetype_html - autocmd! - autocmd FileType html nnoremap <buffer> <localleader>f Vatzf - autocmd BufWrite *.html :normal gg=G - autocmd BufWrite,BufRead *.html setlocal nowrap + autocmd! + autocmd FileType html nnoremap <buffer> <localleader>f Vatzf + autocmd BufWrite *.html :normal gg=G + autocmd BufWrite,BufRead *.html setlocal nowrap augroup END " }}} @@ -274,23 +349,9 @@ augroup END "}}} " Spec file settings ---------------------------------{{{ -augroup FileType_spec - autocmd BufNewFile *.spec call SKEL_spec() -augroup END -" }}} - -" Extra Terminal Stuff ----------------------------- {{{ -" In many terminal emulators the mouse works just fine, thus enable it. -if has('mouse') - set mouse=a -endif - -" Switch syntax highlighting on, when the terminal has colors -" Also switch on highlighting the last used search pattern. -if &t_Co > 2 || has("gui_running") - syntax on - set hlsearch -endif +" augroup FileType_spec +" autocmd BufNewFile *.spec call SKEL_spec() +" augroup END " }}} " vimrcEx ------------------------------------------------------{{{ @@ -307,9 +368,9 @@ augroup vimrcEx " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif augroup END " }}} @@ -320,79 +381,15 @@ augroup END " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis - \ | wincmd p | diffthis + \ | wincmd p | diffthis endif " }}} -" Ctags stuff ----------------------------------------------------------{{{ -set tags+=.tags;/ -" BMS set tags=./tags;$HOME -" BMS set tags+=~/.vim/tags/libc6-dev_tags -" BMS set tags+=~/.vim/tags/cpp_tags -" BMS set tags+=~/.vim/tags/cpp -function! UpdateTags() - execute ":!ctags -R --languages=C++ --c++-kinds=+p --fields=+iaS --extra=+q ./" - echohl StatusLine | echo "C/C++ tag updated" | echohl None -endfunction -nnoremap <F8> :call UpdateTags() -"}}} - -" swap file stuff --------------------------------------------------{{{ -" Save your backups to a less annoying place than the current directory. -" If you have .vim-backup in the current directory, it'll use that. -" Otherwise it saves it to ~/.vim/backup or . if all else fails. -if isdirectory($HOME . '/.vim/backup') == 0 - :silent !mkdir -p ~/.vim/backup >/dev/null 2>&1 -endif -set backupdir-=. -set backupdir+=. -set backupdir-=~/ -set backupdir^=~/.vim/backup/ -set backupdir^=./.vim-backup/ -set backup - -" Save your swp files to a less annoying place than the current directory. -" If you have .vim-swap in the current directory, it'll use that. -" Otherwise it saves it to ~/.vim/swap, ~/tmp or . -if isdirectory($HOME . '/.vim/swap') == 0 - :silent !mkdir -p ~/.vim/swap >/dev/null 2>&1 -endif -set directory=./.vim-swap// -set directory+=~/.vim/swap// -set directory+=~/tmp// -set directory+=. - -" viminfo stores the the state of your previous editing session -set viminfo+=n~/.vim/viminfo - -if exists("+undofile") - " undofile - This allows you to use undos after exiting and restarting - " This, like swap and backups, uses .vim-undo first, then ~/.vim/undo - " :help undo-persistence - " This is only present in 7.3+ - if isdirectory($HOME . '/.vim/undo') == 0 - :silent !mkdir -p ~/.vim/undo > /dev/null 2>&1 - endif - set undodir=./.vim-undo// - set undodir+=~/.vim/undo// - set undofile -endif -"}}} - " sudo writing -------------------------------------------------{{{ cmap w!! w !sudo tee % > /dev/null "}}} -syntax enable -"if has('gui_running') -" set background=light -"else -" let g:solarized_termcolors=16 -" set background=light -"endif -"set background=dark -"colorscheme solarized - +" tabs shortcuts --------------------------------------------{{{ "custom shortcuts "tabs " nnoremap <C-Left> :tabprevious<CR> @@ -401,11 +398,21 @@ syntax enable " inoremap <C-Left> <Esc> :tabprevious<CR>i " inoremap <C-Right><Esc> :tabnext<CR>i " inoremap <C-t> <Esc> :tabnew<CR> +" }}} +" +" Ctags stuff ----------------------------------------------------------{{{ +set tags+=.tags;/ +" BMS set tags=./tags;$HOME +" BMS set tags+=~/.vim/tags/libc6-dev_tags +" BMS set tags+=~/.vim/tags/cpp_tags +" BMS set tags+=~/.vim/tags/cpp +function! UpdateTags() + execute ":!ctags -R --languages=C++ --c++-kinds=+p --fields=+iaS --extra=+q ./" + echohl StatusLine | echo "C/C++ tag updated" | echohl None +endfunction +nnoremap <F8> :call UpdateTags() +"}}} -" set list listchars=tab:»»,trail:•,precedes:â†,extends:→,space:·,eol:¶ -set list listchars=tab:»»,trail:•,precedes:â†,extends:→,space:\ ,eol:¶ - -set clipboard=unnamedplus,unnamed +" Fugitive gitlab setting --------------------------------- {{{ let g:fugitive_gitlab_domains = ['https://git.qoto.org'] - - +" }}} -- GitLab