From f0ea71ef0ac89bb37c9162ae8d388002b7b30d98 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 6 Nov 2019 23:13:16 -0500 Subject: [PATCH] vim: further vimrc cleanup (see log) While splitting my autoload functions into "utils" and "vimrc" was, at the time, a seemingly forward-looking move, I've trended towards slimming down my config over time, and more files is more of a pain to manage. This commit merges all the autoloaded functions (really only two in use...) into one vimrc.vim . It deletes the warn function, which is not currently in use. --- vim/autoload/utils.vim | 23 ----------------------- vim/autoload/vimrc.vim | 14 ++++++++++++++ vim/vimrc | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 vim/autoload/utils.vim diff --git a/vim/autoload/utils.vim b/vim/autoload/utils.vim deleted file mode 100644 index a3e4122..0000000 --- a/vim/autoload/utils.vim +++ /dev/null @@ -1,23 +0,0 @@ -" autoload/utils.vim -- utility functions to support vimrc -" -" See `:h autoload-functions` for explanation of autoloading and performance - -" A function to execute a command and return to the old position -" CREDIT: http://vimcasts.org/episodes/tidying-whitespace/ -function! utils#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 - -function! utils#warn(msg) abort - echohl WarningMsg - echo 'vimrc: ' . a:msg - echohl None -endfunction diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim index e0079b6..71e5b5c 100644 --- a/vim/autoload/vimrc.vim +++ b/vim/autoload/vimrc.vim @@ -12,3 +12,17 @@ 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/vimrc b/vim/vimrc index 8d87f36..6eca629 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -134,7 +134,7 @@ nnoremap l nnoremap :set paste \| put + \| set nopaste " Clear trailing whitespace (through regexp) -nnoremap :call utils#CMDPreserve("%s/\\s\\+$//e") +nnoremap :call vimrc#CMDPreserve("%s/\\s\\+$//e") " edit in current buffer dir nnoremap e :e %:h/ -- libgit2 0.28.4