Browse Source

Trim tailing spaces is a function; list chars defined globally

The regexp used to removed the tailing spaces at the end of lines is now
a function, so it's easier to use it in autocommands.

Also, moved the list chars outside the C syntax auto-command, so we now
have a style that works globally. It's disabled globally too (nolist) so
each syntax can enable (or we can manually enable if needed).
master
Julio Biason 10 years ago
parent
commit
419e14fef1
  1. 24
      configs/vimrc

24
configs/vimrc

@ -58,6 +58,8 @@ set vb t_vb= " convert bells to visual bells and do nothing as visual
set t_Co=256 " 256 color terminals
set modeline " Enable modelines
set undofile " saves undo changes in a separate file, so we can undo anytime
set lcs=tab:¦\ " uses a special char at the start of a tab character, uses spaces after that
set nolist " ... but don't display them by default
let mapleader="," " use comma to start user-defined (in plugins) functions
@ -176,22 +178,29 @@ set wildignore+=*/build/*,*.egginfo,*.pyc,*.mo,*/dist/*
" Auto-commands
" ----------------------------------------------------------------------
" Because most auto-commands add a "trim tailing spaces" regexp, we will
" create a function to do that, so auto-commands can simply :call it.
function TrimWhiteSpace()
%s/\s*$//
''
endfunction
" default python style
" (use spaces instead of tabs (expandtab), uses 4 spaces for tabs (tabstop),
" when auto-indenting, also use 4 spaces (shiftwidth), when deleting text, 4
" spaces are a tab (softtabstop) and break the line at column 78 (textwidth))
" also, remove all tailing spaces
au FileType python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 textwidth=78 colorcolumn=79
au FileType python autocmd BufWritePre <buffer> :%s/\s\+$//e
au FileType python autocmd BufWritePre * :call TrimWhiteSpace()
" Default C/C++ style
" show a column marker at column 100, break the line at line 100, use tabs
" instead of sapces and display a "¦" for tabs (this way we can see the lines
" that are not using real tabs)
au FileType c setlocal colorcolumn=100 tw=100 noet list lcs=tab:¦\
au FileType c autocmd BufWritePre <buffer> :%s/\s\+$//e
au FileType cpp setlocal colorcolumn=100 tw=100 noet list lcs=tab:¦\
au FileType cpp autocmd BufWritePre <buffer> :%s/\s\+$//e
au FileType c setlocal colorcolumn=100 tw=100 noet list
au FileType c autocmd BufWritePre * :call TrimWhiteSpace()
au FileType cpp setlocal colorcolumn=100 tw=100 noet list
au FileType cpp autocmd BufWritePre * :call TrimWhiteSpace()
" Default ReStructured document style
" reStructured files follow python closely, but use 3 tab stops instead of 4
@ -238,14 +247,15 @@ au FileType javascript setlocal expandtab tabstop=2 sw=2 sts=2 textwidth=0
let g:vim_json_syntax_conceal = 0
autocmd BufNewFile,BufRead *.json set filetype=json
autocmd Filetype json set et ts=4 sts=4
autocmd FileType json autocmd BufWritePre <buffer> :%s/\s\+$//e
autocmd FileType json autocmd BufWritePre * :call TrimWhiteSpace()
" Default Pinpoint style
au BufNewFile,BufRead *.pin set filetype=pinpoint
au FileType pinpoint setlocal colorcolumn=79 textwidth=78
" Default Yang style
au FileType yang set et
au FileType yang autocmd BufWritePre * :call TrimWhiteSpace()
" ----------------------------------------------------------------------
" mapings

Loading…
Cancel
Save