From e4ef4fa6eac77dac5d212bc3ed82d1340e6b95f5 Mon Sep 17 00:00:00 2001 From: jdhao Date: Tue, 12 Jan 2021 23:01:49 +0800 Subject: [PATCH] Fix bug for text object for the entire buffer --- autoload/text_obj.vim | 8 ++++++++ core/mappings.vim | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/autoload/text_obj.vim b/autoload/text_obj.vim index 58ba710..4f6a1ff 100644 --- a/autoload/text_obj.vim +++ b/autoload/text_obj.vim @@ -76,3 +76,11 @@ function! text_obj#MdCodeBlock(type) abort call setpos("'>", [buf_num, end_row, 1, 0]) execute 'normal! `' endfunction + +function! text_obj#Buffer() abort + let buf_num = bufnr() + + call setpos("'<", [buf_num, 1, 1, 0]) + call setpos("'>", [buf_num, line('$'), 1, 0]) + execute 'normal! `' +endfunction diff --git a/core/mappings.vim b/core/mappings.vim index a7c76c9..eba7106 100644 --- a/core/mappings.vim +++ b/core/mappings.vim @@ -186,6 +186,6 @@ xnoremap iu :call text_obj#URL() onoremap iu :call text_obj#URL() " Text objects for entire buffer -xnoremap iB 0ggoG -onoremap iB :normal viB +xnoremap iB :call text_obj#Buffer() +onoremap iB :call text_obj#Buffer() "}