From f1a298d36c83b9d0e9fde072db88c0be314bcb31 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Fri, 2 Jul 2021 23:28:01 -0400 Subject: [PATCH] vim: Remove function from vimcasts.org I'm on a mission to one day release my dotfiles under a FOSS license. Before that can happen, I want to make sure the code is all mine! --- .vim/autoload/vimrc.vim | 14 -------------- .vim/improved.vim | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.vim/autoload/vimrc.vim b/.vim/autoload/vimrc.vim index 71e5b5c..e0079b6 100644 --- a/.vim/autoload/vimrc.vim +++ b/.vim/autoload/vimrc.vim @@ -12,17 +12,3 @@ function! vimrc#ToggleColorColumn() abort set colorcolumn="" endif endfunction - -" A function to execute a command and return to the old position -" CREDIT: http://vimcasts.org/episodes/tidying-whitespace/ -function! vimrc#CMDPreserve(command) abort - " Preparation: save last search, and cursor position. - let _s=@/ - let l = line(".") - let c = col(".") - " Do the business: - execute a:command - " Clean up: restore previous search history, and cursor position - let @/=_s - call cursor(l, c) -endfunction diff --git a/.vim/improved.vim b/.vim/improved.vim index 55f6867..52dd0b8 100644 --- a/.vim/improved.vim +++ b/.vim/improved.vim @@ -94,7 +94,7 @@ nnoremap l nnoremap :set paste \| put + \| set nopaste " Clear trailing whitespace (through regexp) -nnoremap :call vimrc#CMDPreserve("%s/\\s\\+$//e") +nnoremap :%s/\s\+$//e " edit in current buffer dir nnoremap e :e %:h/ -- libgit2 0.28.4