Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some sort of indicator if a file has both tabs AND spaces as indentation #13

Closed
scottchiefbaker opened this issue Jul 28, 2014 · 2 comments

Comments

@scottchiefbaker
Copy link

If a file has both spaces AND tabs as indentation it would be very handy if vim-slueth would pop up some sort of warning that indentation is inconsistent, so that I know I need to fix it.

@krader1961
Copy link

I don't speak for Tim but personally I think this isn't appropriate for vim-sleuth. To let me know of possible whitespace problems I have the following in ~/.vim/plugin/bad-whitespace.vim. Obviously if you have some file types where mixed tabs/spaces are valid you'll want to tweak this to only apply to the appropriate file types.

" Make trailing whitespace on a line highly visible and make it easy to
" remove it. Also flag leading mixed spaces/tabs.
if exists('g:loaded_bad_whitespace')
  finish
endif
let g:did_load_trailing_whitespace = 1

" Highlight trailing whitespace and leading mixed tabs/spaces.
highlight ExtraWhitespace ctermbg=darkred guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\v^\s*( \t|\t )\s*|\s+$/

" The above flashes annoyingly while typing, be calmer in insert mode
autocmd InsertLeave * match ExtraWhitespace /\v^\s*( \t|\t )\s*|\s+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/

function! s:FixWhitespace(line1,line2)
    let l:save_cursor = getpos(".")
    silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//'
    call setpos('.', l:save_cursor)
endfunction

" Run :TrimSpaces or :FixWhitespace to remove trailing white space.
command! -range=% TrimSpaces    call <SID>FixWhitespace(<line1>,<line2>)
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)

@tpope
Copy link
Owner

tpope commented Dec 3, 2021

Personally I wouldn't find this particularly helpful. For every one time I make this mistake myself, I have a hundred where I'm dealing with someone else's jank file, and I really don't want Sleuth twisting the knife with a nagging message. But the reason I'm going to say no is there just isn't a good way to deliver that message. Anything that interrupts the user with a "press ENTER" prompt sounds positively insufferable.

@tpope tpope closed this as completed Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants