summaryrefslogtreecommitdiff
path: root/.config/nvim/general/functions.vim
blob: 07a67c4bab636e99f7e48f2567420073d6d93c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR>