From 8d5624a4dbf52a6057ccbc4a28b43df10bf421ea Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Tue, 20 Oct 2020 17:09:33 +0100 Subject: Modulise nvim configuration --- .config/nvim/general/functions.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .config/nvim/general/functions.vim (limited to '.config/nvim/general/functions.vim') diff --git a/.config/nvim/general/functions.vim b/.config/nvim/general/functions.vim new file mode 100644 index 0000000..07a67c4 --- /dev/null +++ b/.config/nvim/general/functions.vim @@ -0,0 +1,12 @@ +function! 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 :call StripTrailingWhitespaces() -- cgit v1.2.3-13-gbd6f