Fix removal of extra white spaces
This commit is contained in:
		
							parent
							
								
									7e69b65e76
								
							
						
					
					
						commit
						3f25b72edb
					
				
							
								
								
									
										28
									
								
								vimrc
								
								
								
								
							
							
						
						
									
										28
									
								
								vimrc
								
								
								
								
							|  | @ -124,11 +124,12 @@ nmap <leader>x :w<cr>:!./"%"<cr> | |||
| " Édition rapide de vimrc avec <leader>+e | ||||
| map <leader>e :e! ~/.vim/vimrc<cr> | ||||
| 
 | ||||
| """ 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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue