Add strip whitespace and check on write
Change-Id: I73ac4260a379c208b1574a934fdbdfb191e5f152
This commit is contained in:
22
.vimrc
22
.vimrc
@@ -16,6 +16,7 @@ if filereadable(expand(vundle_dir) . "/README.md")
|
|||||||
Plugin 'tpope/vim-fugitive'
|
Plugin 'tpope/vim-fugitive'
|
||||||
Plugin 'tpope/vim-surround'
|
Plugin 'tpope/vim-surround'
|
||||||
Plugin 'ctrlpvim/ctrlp.vim'
|
Plugin 'ctrlpvim/ctrlp.vim'
|
||||||
|
Plugin 'rhysd/vim-clang-format'
|
||||||
" Plugin 'shougo/neocomplete'
|
" Plugin 'shougo/neocomplete'
|
||||||
Plugin 'godlygeek/tabular'
|
Plugin 'godlygeek/tabular'
|
||||||
|
|
||||||
@@ -26,6 +27,8 @@ else
|
|||||||
command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir
|
command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
highlight Search ctermbg=5
|
||||||
|
|
||||||
filetype plugin indent on " required
|
filetype plugin indent on " required
|
||||||
syntax on
|
syntax on
|
||||||
|
|
||||||
@@ -36,6 +39,25 @@ set expandtab " On pressing tab, insert 4 spaces
|
|||||||
set mouse=a
|
set mouse=a
|
||||||
set hlsearch
|
set hlsearch
|
||||||
|
|
||||||
|
" Warn for trailing whitespace. Search with wrap (w) do not move cursor (n)
|
||||||
|
function! WhitespaceWarn()
|
||||||
|
echohl WarningMsg
|
||||||
|
echo 'Found whitespace.'
|
||||||
|
echohl None
|
||||||
|
echon ' Type :TrailWhitespace to remove it'
|
||||||
|
endfunction
|
||||||
|
function! StripTrailingWhitespace()
|
||||||
|
" Save cursor position
|
||||||
|
let l:save = winsaveview()
|
||||||
|
" Remove trailing whitespace
|
||||||
|
%s/\s\+$//e
|
||||||
|
" Move cursor to original position
|
||||||
|
call winrestview(l:save)
|
||||||
|
echo "Stripped trailing whitespace"
|
||||||
|
endfunction
|
||||||
|
autocmd BufWritePost * if search('\s\+$', 'wn') | call WhitespaceWarn() | endif
|
||||||
|
command TrailWhitespace call StripTrailingWhitespace()
|
||||||
|
|
||||||
" Hybrid line numbers on active buffer
|
" Hybrid line numbers on active buffer
|
||||||
set nu rnu
|
set nu rnu
|
||||||
augroup numbertoggle
|
augroup numbertoggle
|
||||||
|
|||||||
Reference in New Issue
Block a user