From 810cfea9c8a86174c425220ae2c55e8919c9959e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 16:55:15 +1200 Subject: Adapt :browse :oldfiles mapping into plugin Just to avoid a hit-enter prompt by limiting it to just short of the vertical size of the screen, with a temporary array slice of v:oldfiles. --- vim/autoload/select_old_files.vim | 7 +++++++ vim/plugin/select_old_files.vim | 6 ++++++ vim/vimrc | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 vim/autoload/select_old_files.vim create mode 100644 vim/plugin/select_old_files.vim diff --git a/vim/autoload/select_old_files.vim b/vim/autoload/select_old_files.vim new file mode 100644 index 00000000..518b98d4 --- /dev/null +++ b/vim/autoload/select_old_files.vim @@ -0,0 +1,7 @@ +function! select_old_files#() abort + let oldfiles = v:oldfiles + let limit = get(g:, 'select_old_files_limit', &lines - 1) + let v:oldfiles = v:oldfiles[:limit-2] + browse oldfiles + let v:oldfiles = oldfiles +endfunction diff --git a/vim/plugin/select_old_files.vim b/vim/plugin/select_old_files.vim new file mode 100644 index 00000000..dbfbd64c --- /dev/null +++ b/vim/plugin/select_old_files.vim @@ -0,0 +1,6 @@ +if exists('loaded_select_old_files') + finish +endif +let loaded_select_old_files = 1 +command! -bar SelectOldFiles + \ call select_old_files#() diff --git a/vim/vimrc b/vim/vimrc index e63a232b..2bcf9943 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1445,7 +1445,7 @@ nnoremap j \ :buffers:buffer "" Leader,o opens a screenful of :browse :oldfiles, ready for a selection nnoremap o - \ :browse :oldfilesq + \ :SelectOldFiles " This ground defines mappings for filtering and batch operations to clean up " buffer text. All of these mappings use commands from my custom plugins: -- cgit v1.2.3