Add a function to search 2 whitespaces " "

This commit is contained in:
Jeremy Gardais 2016-06-27 14:56:45 +02:00
parent 2cd5bc21ed
commit f37b07b14d
1 changed files with 21 additions and 3 deletions

22
vimrc
View File

@ -872,14 +872,32 @@ au BufWritePost * call ModeChange()
" Display '␠' to mark extra white space at the end of a line " Display '␠' to mark extra white space at the end of a line
" Display '⎵' to mark nbsp (fixed spaces,…) " Display '⎵' to mark nbsp (fixed spaces,…)
set list set list
set listchars=eol:⏎,nbsp:⎵,tab:▸·,trail:␠ set listchars=eol:⏎,nbsp:⎵,tab:▸·,extends:>,precedes:<,trail:␠
" Afficher les espaces superflus en gris clair " Afficher les espaces superflus en gris clair
highlight ExtraWhitespace ctermbg=darkgray guibg=lightred highlight ExtraWhitespace ctermbg=darkgray guibg=lightred
match ExtraWhitespace /\s\+$/ match ExtraWhitespace /\s\+$/
" Suppression automatique des espaces superflus (avant sauvegarde) " Auto-remove extra whitespaces before writing the file
autocmd BufWritePre * :%s/\s\+$//e autocmd BufWritePre * :%s/\s\+$//e
" Search for 2 whitespaces and highlight it (red and underline)
set hls
let g:HLSpace = 1
let g:HLColorScheme = g:colors_name
function ToggleSpaceUnderscoring()
if g:HLSpace
highlight Search cterm=underline gui=underline ctermbg=red ctermfg=none
let @/ = " "
else
highlight clear
silent colorscheme "".g:HLColorScheme
let @/ = ""
endif
let g:HLSpace = !g:HLSpace
endfunction
nmap <silent> <F3> <Esc>:call ToggleSpaceUnderscoring()<CR>
"################################ "################################
" Configuration BÉPO " Configuration BÉPO