mirror of
https://github.com/gryf/.vim.git
synced 2025-12-17 19:40:29 +01:00
Added possibilty to turn off removing trailing spaces
This commit is contained in:
25
.vimrc
25
.vimrc
@@ -22,7 +22,7 @@ NeoBundle "gryf/zoom.vim"
|
|||||||
NeoBundle "hallison/vim-markdown"
|
NeoBundle "hallison/vim-markdown"
|
||||||
NeoBundle "honza/vim-snippets"
|
NeoBundle "honza/vim-snippets"
|
||||||
NeoBundle "http://repo.or.cz/r/vcscommand.git"
|
NeoBundle "http://repo.or.cz/r/vcscommand.git"
|
||||||
NeoBundle "https://code.google.com/p/vimwiki/"
|
NeoBundle "vimwiki/vimwiki"
|
||||||
NeoBundle "kazuyukitanimura/jsbeautify"
|
NeoBundle "kazuyukitanimura/jsbeautify"
|
||||||
NeoBundle "kevinw/pyflakes-vim"
|
NeoBundle "kevinw/pyflakes-vim"
|
||||||
NeoBundle "kien/ctrlp.vim"
|
NeoBundle "kien/ctrlp.vim"
|
||||||
@@ -131,6 +131,10 @@ set noswapfile
|
|||||||
"in case they are needed, store swapfiles in tmp
|
"in case they are needed, store swapfiles in tmp
|
||||||
"set dir=~/tmp/
|
"set dir=~/tmp/
|
||||||
|
|
||||||
|
" Strip trailing whitespace option
|
||||||
|
let stripTrailingWhitespace = 1
|
||||||
|
|
||||||
|
|
||||||
" TOhtml options
|
" TOhtml options
|
||||||
let html_number_lines = 1
|
let html_number_lines = 1
|
||||||
let html_use_css = 1
|
let html_use_css = 1
|
||||||
@@ -143,12 +147,7 @@ let g:browser = 'firefox'
|
|||||||
"COMMON: specific vim behaviour {{{
|
"COMMON: specific vim behaviour {{{
|
||||||
"
|
"
|
||||||
"remove all trailing whitespace for specified files before write
|
"remove all trailing whitespace for specified files before write
|
||||||
autocmd BufWritePre *.py :call <SID>StripTrailingWhitespaces()
|
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces(0)
|
||||||
autocmd BufWritePre *.rst :call <SID>StripTrailingWhitespaces()
|
|
||||||
autocmd BufWritePre *.wiki :call <SID>StripTrailingWhitespaces()
|
|
||||||
autocmd BufWritePre *.js :call <SID>StripTrailingWhitespaces()
|
|
||||||
autocmd BufWritePre *.css :call <SID>StripTrailingWhitespaces()
|
|
||||||
autocmd BufWritePre *.xml :call <SID>StripTrailingWhitespaces()
|
|
||||||
"set correct filetype for tmux
|
"set correct filetype for tmux
|
||||||
autocmd BufRead *.tmux.conf set filetype=tmux
|
autocmd BufRead *.tmux.conf set filetype=tmux
|
||||||
autocmd BufRead *.mako set filetype=mako
|
autocmd BufRead *.mako set filetype=mako
|
||||||
@@ -295,7 +294,7 @@ map <S-F9> :QFix<CR>
|
|||||||
map <S-F11> :LWin<CR>
|
map <S-F11> :LWin<CR>
|
||||||
|
|
||||||
"remove trailing whitespaces
|
"remove trailing whitespaces
|
||||||
nnoremap <leader>e :StripTrailingWhitespaces<CR>
|
nnoremap <leader>e :StripTrailingWhitespaces!<CR>
|
||||||
|
|
||||||
" copy current buffer filename (full path)
|
" copy current buffer filename (full path)
|
||||||
nmap ,cn :silent call <SID>CopyFileName(1)<CR>
|
nmap ,cn :silent call <SID>CopyFileName(1)<CR>
|
||||||
@@ -350,7 +349,12 @@ function <SID>Make()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Remove trailing whitespace
|
" Remove trailing whitespace
|
||||||
function <SID>StripTrailingWhitespaces()
|
function <SID>StripTrailingWhitespaces(force)
|
||||||
|
if a:force != 1 && g:stripTrailingWhitespace == 0
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:force == 1 || &ft =~ 'python\|rst\|wiki\|javascript\|css\|html\|xml'
|
||||||
" Preparation: save last search, and cursor position.
|
" Preparation: save last search, and cursor position.
|
||||||
let _s=@/
|
let _s=@/
|
||||||
let l = line(".")
|
let l = line(".")
|
||||||
@@ -360,8 +364,9 @@ function <SID>StripTrailingWhitespaces()
|
|||||||
" Clean up: restore previous search history, and cursor position
|
" Clean up: restore previous search history, and cursor position
|
||||||
let @/=_s
|
let @/=_s
|
||||||
call cursor(l, c)
|
call cursor(l, c)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
command StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
|
command -bang StripTrailingWhitespaces call <SID>StripTrailingWhitespaces(<bang>0)
|
||||||
|
|
||||||
function <SID>CopyFileName(full)
|
function <SID>CopyFileName(full)
|
||||||
if a:full
|
if a:full
|
||||||
|
|||||||
Reference in New Issue
Block a user