-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmappings.vim
29 lines (26 loc) · 1000 Bytes
/
mappings.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
" Various Functions/autocommands
" "jump to last cursor position when opening a file
" "dont do it when writing a commit log entry
" function! SetCursorPosition()
" if &filetype !~ 'commit\c'
" if line("'\"") > 0 && line("'\"") <= line("$")
" exe "normal g`\""
" endif
" end
" endfunction
" autocmd BufReadPost * call SetCursorPosition()
" http://vimcasts.org/episodes/tidying-whitespace/
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" when would I NOT want to strip trailing whitespace?
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" autocmd BufWritePre *.md,*.markdown,*.sql,*.sh,*.scala,*.sbt,*.go,*.py,*.js,*pp,*.c,*.cc,*.h,*.rb,*.y*ml :call <SID>StripTrailingWhitespaces()