aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorCody Hiar <cody@hiar.ca>2021-03-09 16:30:24 -0700
committerCody Hiar <cody@hiar.ca>2021-03-09 16:30:24 -0700
commitee3732014d69d1f00a9e8cf87045100893da73e6 (patch)
tree1e1a7d12b78cd6ca1eccb5bb58fb905a15827a24 /plugin
parent92d08970c2e09c6799cf2c9a03f982a23c950a89 (diff)
Better command for striping whitespace and saving cursor position
Diffstat (limited to 'plugin')
-rw-r--r--plugin/vim-options.vim20
1 files 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 <leader>ep ofrom pudb import set_trace; set_trace()<ESC>
noremap <c-w>f <c-w>f<c-w>L
" Follow file into new tab
noremap <c-w><c-f> <c-w>f<c-w>T
-" <c-w>] uses path not tags file?
+" <c-w>] uses path not tags file?
noremap <c-w>] <c-w>v<c-]><c-w>L
" <c-w>] to new tab
noremap <c-w><c-]> <c-w>v<c-]><c-w>T
@@ -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'],