Improved visible whitespace stuff
Median dots for spaces, pilcrow at end of lines
This commit is contained in:
parent
6f703fcbb9
commit
e62de27044
1 changed files with 21 additions and 16 deletions
|
@ -1,12 +1,14 @@
|
||||||
" Trailing spaces and visible tabs
|
" Trailing spaces and visible tabs
|
||||||
"
|
"
|
||||||
" Trailing spaces are visible in normal or visual mode, but hidden in insert
|
" Trailing spaces are visible in normal or visual mode, but hidden in insert
|
||||||
" mode. Tabs can be displayed or hidden using <Leader>T.
|
" mode. All whitespace can be made visible using <Leader>ow
|
||||||
|
|
||||||
set list
|
let s:Settings = {
|
||||||
set listchars=""
|
\ 'tab' : [ " " , "» " ] ,
|
||||||
set listchars+=trail:•
|
\ 'nbsp' : [ " " , "⚠" ] ,
|
||||||
set listchars+=tab:\ \
|
\ 'space' : [ " " , "·" ] ,
|
||||||
|
\ 'eol' : [ " " , "¶" ] ,
|
||||||
|
\ }
|
||||||
let s:VisibleTabs = 0
|
let s:VisibleTabs = 0
|
||||||
|
|
||||||
function! s:UpdateListChars(type,value)
|
function! s:UpdateListChars(type,value)
|
||||||
|
@ -14,19 +16,22 @@ function! s:UpdateListChars(type,value)
|
||||||
let &l:listchars = join( lc , "," )
|
let &l:listchars = join( lc , "," )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! <SID>SwitchVisibleTabs()
|
function! s:ApplyWhitespaceSettings()
|
||||||
if s:VisibleTabs == 1
|
for k in keys(s:Settings)
|
||||||
let s:VisibleTabs = 0
|
call s:UpdateListChars( k , s:Settings[k][s:VisibleTabs] )
|
||||||
call s:UpdateListChars( "tab" , " " )
|
endfor
|
||||||
call s:UpdateListChars( "nbsp" , " " )
|
|
||||||
else
|
|
||||||
let s:VisibleTabs = 1
|
|
||||||
call s:UpdateListChars( "tab" , "» " )
|
|
||||||
call s:UpdateListChars( "nbsp" , "⚠" )
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
nnoremap <silent> <Leader>T :call <SID>SwitchVisibleTabs()<cr>
|
function! <SID>ToggleVisibleWhitespace()
|
||||||
|
let s:VisibleTabs = 1 - s:VisibleTabs
|
||||||
|
call s:ApplyWhitespaceSettings()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
set list
|
||||||
|
set listchars=""
|
||||||
|
call s:ApplyWhitespaceSettings()
|
||||||
|
|
||||||
|
nnoremap <silent> <Leader>ow :call <SID>ToggleVisibleWhitespace()<cr>
|
||||||
augroup TrailingWhitespace
|
augroup TrailingWhitespace
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd InsertEnter * :call <SID>UpdateListChars( "trail" , " " )
|
autocmd InsertEnter * :call <SID>UpdateListChars( "trail" , " " )
|
||||||
|
|
Loading…
Reference in a new issue