Closed wizzup closed 7 years ago
I personally use a function which automatically removes trailing spaces, and I draw tab characters.
set listchars=tab:>~
set list
fun! TrimWhitespace()
let line_no = line('.')
let col_no = col('.')
%s/\s*$//
call cursor(line_no, col_no)
endf
" Do auto whitespace trimming.
autocmd FileWritePre * :call TrimWhitespace()
autocmd FileAppendPre * :call TrimWhitespace()
autocmd FilterWritePre * :call TrimWhitespace()
autocmd BufWritePre * :call TrimWhitespace()
I wrote those lines a long, long time ago, and I've been using that for ages.
A mix of tabs and spaces isn't necessarily an error for every type of file. It might be required for some formats.
autocommand
is a good solution.
vim-airline is warned about trailing space but only after the file is saved and it only show the first one.
I am using
set list
in my config but it easy to miss, when code is big.Is there anyway to have these kind of linters that can be use on any filetype.