diff --git a/vimrc b/vimrc index b124c58..10f746d 100644 --- a/vimrc +++ b/vimrc @@ -124,11 +124,12 @@ nmap x :w:!./"%" " Édition rapide de vimrc avec +e map e :e! ~/.vim/vimrc -""" Splits {{{ +" Splits {{{ " Open new split on the bottom part set splitbelow " Open new split on the right part set splitright +" }}} " FZF function to list all files on the system {{{ function! FzfFiles() @@ -1011,15 +1012,34 @@ au BufWritePost * call ModeChange() set list "set listchars=eol:⏎,nbsp:⎵,tab:▸·,extends:>,precedes:<,trail:␠ set listchars=nbsp:⎵,tab:▸·,extends:>,precedes:<,trail:␠ -" Afficher les espaces superflus en gris clair + +" Manage ExtraWhiteSpace {{{ +" Display ExtraWhiteSpace (spaces at the End Of the Line) in gray highlight ExtraWhitespace ctermbg=darkgray guibg=lightred match ExtraWhitespace /\s\+$/ -" Auto-remove extra whitespaces before writing the file -autocmd BufWritePre * :%s/\s\+$//e +" Function to clean it +function! CleanTrailingWhitespace() +" https://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except + " Specific sed command for mail filetype + if &ft =~ 'mail' + " Want to keep email's signature (begin with "--" + one extra whitespace). + " https://stackoverflow.com/questions/45294980/in-sed-how-to-do-a-pattern-substitution-only-when-another-pattern-doesnt-exist + :g!/^--/s/\s\+$//g + return + endif + " Default sed command on all other filetypes + %s/\s\+$//e +endfunction + +" Call function before saving +autocmd BufWritePre * call CleanTrailingWhitespace() +" }}} + " Auto-remove extra ⏎ before writing the file autocmd BufWritePre * :%s/⏎\+$//e + " Search for 2 whitespaces and highlight it (red and underline) set hls let g:HLSpace = 1