From ee3732014d69d1f00a9e8cf87045100893da73e6 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Tue, 9 Mar 2021 16:30:24 -0700 Subject: Better command for striping whitespace and saving cursor position --- plugin/vim-options.vim | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugin/vim-options.vim b/plugin/vim-options.vim index f9a87e0..3e5511a 100644 --- a/plugin/vim-options.vim +++ b/plugin/vim-options.vim @@ -37,7 +37,7 @@ au FileType make setlocal tabstop=4 noexpandtab au FileType markdown set tw=80 tabstop=2 " Setup colorscheme -syntax enable +syntax enable colorscheme nord " Set the colorscheme set background=dark " Use dark colorscheme @@ -56,7 +56,15 @@ au BufEnter *.py let w:m1=matchadd('ColorColumn', '\%81v', 100) au BufEnter *.py let w:m2=matchadd('Error', '\%121v', 100) au BufLeave *.py call clearmatches() " Remove trailing space on save but use sed to maintain cursor position -autocmd BufWritePre * :%!sed -r 's/\s+$//' +function! StripTrailingWhitespaces() + if !&binary && &filetype != 'diff' + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) + endif +endfun +autocmd BufWritePre,FileWritePre,FileAppendPre,FilterWritePre * + \ :call StripTrailingWhitespaces() " Neovim (Docker) vs Vim @@ -112,7 +120,7 @@ noremap ep ofrom pudb import set_trace; set_trace() noremap f fL " Follow file into new tab noremap fT -" ] uses path not tags file? +" ] uses path not tags file? noremap ] vL " ] to new tab noremap vT @@ -235,7 +243,7 @@ if !empty(glob($EditorDir.'plugged/vim-indent-guides/plugin/indent_guides.vim')) let g:indent_guides_guide_size = 1 au VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=235 au VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=237 - au BufEnter *.py,*.html :IndentGuidesEnable + au BufEnter *.py,*.html :IndentGuidesEnable au BufLeave *.py,*.html :IndentGuidesDisable endif "----------------------------------------------------------------------------------------------------------------------- @@ -272,7 +280,7 @@ if !empty(glob($EditorDir.'plugged/ale/autoload/ale.vim')) let g:ale_sign_column_always = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_python_mypy_options='--ignore-missing-imports --disallow-untyped-defs' - let g:ale_history_enabled = 0 + let g:ale_history_enabled = 0 highlight clear ALEErrorSign highlight clear ALEWarningSign " Change gutter color @@ -296,7 +304,7 @@ if !empty(glob($EditorDir.'plugged/rainbow_parentheses.vim/plugin/rainbow_parent au BufEnter *.py call EnableRainbows() au Syntax *.py RainbowParenthesesLoadRound au Syntax *.py RainbowParenthesesLoadSquare - au Syntax *.py RainbowParenthesesLoadBraces + au Syntax *.py RainbowParenthesesLoadBraces let g:rbpt_colorpairs = [ \ ['darkblue', 'RoyalBlue3'], \ ['magenta', 'DarkOrchid3'], -- cgit v1.2.3